Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - h2oskier

Pages: [1]
1
General Board / Re: Method and Attribute Grouping By Visibility
« on: February 01, 2007, 01:19:55 pm »
Thanks Simon.  I appreciate you pointing this out.  Below is the updated C# class body template with the null keyword replaced with an empty string.

%if elemType == "Interface"%
{\n
%list="Operation" @separator="\n\n" @indent="\t"%
%PI=""%
} // %className%
%endTemplate%

\n{\n
%PI="\n\n"%
%list="InnerClass" @separator="\n\n" @indent="\t"%

$COMMENT="output attribute region only if there are attributea"
$attribute=%list="Attribute"%
%if $attribute!=""%
#region Attributes
$COMMENT="output constants in public/protected/private order"
%list="Attribute" @separator="\n" @indent="\t" attScope=="Public" and attConst=="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Protected" and attConst=="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Private" and attConst=="T"%

$COMMENT="output variables in public/protected/private order"
%list="Attribute" @separator="\n" @indent="\t" attScope=="Public" and attConst!="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Protected" and attConst!="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Private" and attConst!="T"%
#endregion  // Attributes
%endIf%

$COMMENT="output constructor region only if there are constructors"
$constructors=%list="Operation" opName==className%
%if $constructors!=""%
#region Constructors
$ops=""
%if genOptGenConstructor == "T" and classHasConstructor != "T"%
$ops+="\tpublic "+%className%+"()\n{\n\n\t}"
%endIf%
$COMMENT="output constructors in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName==className and opScope=="Public"%
%list="Operation" @separator="\n\n" @indent="\t" opName==className and opScope=="Protected"%
%list="Operation" @separator="\n\n" @indent="\t" opName==className and opScope=="Private"%
#endregion  // Constructors
%endIf%

%if genOptGenDestructor == "T" and classHasDestructor != "T" and classHasFinalizer != "T"%
$ops+="\n\n\t~"+%className%+"()\n{\n\n\t}"
%endIf%

%if genOptCSGenDispose == "T" and classHasDispose != "T"%
$ops+="\n\n\tpublic "
$ops+=%classHasParent=="T" ? "override " : "virtual "%
$ops+="void Dispose(){\n\n\t}"
%endIf%

%if genOptCSGenFinalizer == "T" and genOptGenDestructor != "T" and classHasFinalizer != "T" and classHasDestructor != "T"%
$ops+="\n\n\tprotected "
$ops+=%classHasParent=="T" ? "override " : "virtual "%
$ops+="void Finalize()\n{\n"
$ops+=%classHasParent=="T" ? "\t\tbase.Finalize();" : ""% + "\n\t}"
%endIf%

%if genOptGenCopyConstructor == "T" and classHasCopyConstructor != "T"%
$ops+="\n\n\tpublic "
$ops+=%className%+"("+%className%+" the"+%className%+")\n{\n\n\t}"
%endIf%

$ops
$COMMENT="output property region only if there are properties"
$propertys=%list="Operation" opName!=className and opTag:"attribute_name"!=""%
%if $propertys!=""%
#region Properties
$COMMENT="output properties in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Public" and opTag:"attribute_name"!=""%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Protected" and opTag:"attribute_name"!=""%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Private" and opTag:"attribute_name"!=""%
#endregion  // Properties
%endIf%

$COMMENT="output methods region only if there are methods"
$methods=%list="Operation" opName!=className and opTag:"attribute_name"==""%
%if $methods!=""%
#region Methods
$COMMENT="output operations in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Public" and opTag:"attribute_name"==""%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Protected" and opTag:"attribute_name"==""%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Private" and opTag:"attribute_name"==""%
#endregion  // Methods
%endIf%

} // %className%


2
General Board / Re: Method and Attribute Grouping By Visibility
« on: February 01, 2007, 11:10:44 am »
I found another way that is working fine.  I am using the presence (or absence) of the attribute_name tag to identify if an operation is a property or a method as follows:

$COMMENT="output properties in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Public" and opTag:"attribute_name"!=null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Protected" and opTag:"attribute_name"!=null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Private" and opTag:"attribute_name"!=null%

$COMMENT="output operations in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Public" and opTag:"attribute_name"==null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Protected" and opTag:"attribute_name"==null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Private" and opTag:"attribute_name"==null%

For those who have been following the full thread.  Here is the C# class body template that I am using to group constants, instance variables, constructors, properties and methods by visibility:  I hope this is helpful.

%if elemType == "Interface"%
{\n
%list="Operation" @separator="\n\n" @indent="\t"%
%PI=""%
} // %className%
%endTemplate%

\n{\n
%PI="\n\n"%
%list="InnerClass" @separator="\n\n" @indent="\t"%

$COMMENT="output attribute region only if there are attributea"
$attribute=%list="Attribute"%
%if $attribute!=null%
#region Attributes
$COMMENT="output constants in public/protected/private order"
%list="Attribute" @separator="\n" @indent="\t" attScope=="Public" and attConst=="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Protected" and attConst=="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Private" and attConst=="T"%

$COMMENT="output variables in public/protected/private order"
%list="Attribute" @separator="\n" @indent="\t" attScope=="Public" and attConst!="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Protected" and attConst!="T"%
%list="Attribute" @separator="\n" @indent="\t" attScope=="Private" and attConst!="T"%
#endregion  // Attributes
%endIf%

$COMMENT="output constructor region only if there are constructors"
$constructors=%list="Operation" opName==className%
%if $constructors!=null%
#region Constructors
$ops=""
%if genOptGenConstructor == "T" and classHasConstructor != "T"%
$ops+="\tpublic "+%className%+"()\n{\n\n\t}"
%endIf%
$COMMENT="output constructors in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName==className and opScope=="Public"%
%list="Operation" @separator="\n\n" @indent="\t" opName==className and opScope=="Protected"%
%list="Operation" @separator="\n\n" @indent="\t" opName==className and opScope=="Private"%
#endregion  // Constructors
%endIf%

%if genOptGenDestructor == "T" and classHasDestructor != "T" and classHasFinalizer != "T"%
$ops+="\n\n\t~"+%className%+"()\n{\n\n\t}"
%endIf%

%if genOptCSGenDispose == "T" and classHasDispose != "T"%
$ops+="\n\n\tpublic "
$ops+=%classHasParent=="T" ? "override " : "virtual "%
$ops+="void Dispose(){\n\n\t}"
%endIf%

%if genOptCSGenFinalizer == "T" and genOptGenDestructor != "T" and classHasFinalizer != "T" and classHasDestructor != "T"%
$ops+="\n\n\tprotected "
$ops+=%classHasParent=="T" ? "override " : "virtual "%
$ops+="void Finalize()\n{\n"
$ops+=%classHasParent=="T" ? "\t\tbase.Finalize();" : ""% + "\n\t}"
%endIf%

%if genOptGenCopyConstructor == "T" and classHasCopyConstructor != "T"%
$ops+="\n\n\tpublic "
$ops+=%className%+"("+%className%+" the"+%className%+")\n{\n\n\t}"
%endIf%

$ops
$COMMENT="output property region only if there are properties"
$propertys=%list="Operation" opName!=className and opScope=="Public" and opTag:"attribute_name"!=null%
%if $propertys!=null%
#region Properties
$COMMENT="output properties in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Public" and opTag:"attribute_name"!=null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Protected" and opTag:"attribute_name"!=null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Private" and opTag:"attribute_name"!=null%
#endregion  // Properties
%endIf%

$COMMENT="output methods region only if there are methods"
$methods=%list="Operation" opName!=className and opScope=="Public" and opTag:"attribute_name"==null%
%if $methods!=null%
#region Methods
$COMMENT="output operations in public/protected/private order"
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Public" and opTag:"attribute_name"==null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Protected" and opTag:"attribute_name"==null%
%list="Operation" @separator="\n\n" @indent="\t" opName!=className and opScope=="Private" and opTag:"attribute_name"==null%
#endregion  // Methods

} // %className%


3
General Board / Re: Method and Attribute Grouping By Visibility
« on: January 31, 2007, 05:38:05 am »
Thanks Simon.  That works great.  To extend it a little further I would like to group properties separate from other methods.  What should I use to identify a property from a method?

Thanks,
Michael

4
General Board / Method and Attribute Grouping By Visibility
« on: January 29, 2007, 09:11:13 am »
When generating code is it possible to group methods and attributes by their visibility?  In other words put all of the public methods first, followed by the protected, and then the private.  It would also be nice to group the constructors together.

Thanks,
Michael

5
General Board / XML Comments
« on: September 26, 2006, 12:14:22 pm »
Is there a way to change the formatting of the XML comments generated by the xml_comment function in the code templates.

6
General Board / Re: Link Use Case to Sequence Diagram
« on: July 17, 2006, 07:36:12 am »
Thank you TrtnJohn.  You have saved my team a lot of time with this information.

7
General Board / Link Use Case to Sequence Diagram
« on: June 01, 2006, 10:24:15 am »
Can anyone tell me how to link a use case to sequence diagram in the manner that is EAExample - Manage Users diagram where the use case itself can be clicked to open the sequence diagram.  I am familiar with how to create hyperlinks on a page; however, the referenced example model makes the use case the link and the use case has a link symbol included in it.

Thanks in advance.

8
General Board / Copying Methods In N-tier Design
« on: July 12, 2006, 07:37:10 am »
When modeling an n-tier application it is quite common to have methods in the business tier and data tier with identical signatures.  How can I copy a method from one class to another?  I have not found any way to do this and entering the same information multiple times is tedious and time consuming.  In addition, it can result in inconsistency in the model.

9
General Board / Modeling with C# Generics
« on: June 08, 2006, 07:07:34 am »
What is the recommended approach to modeling operations where parameters and/or return types are C# generics such as List<T>?

Pages: [1]