[DOTNET] Aesthetics Question on the CodeDOM
by Justin Rudd other posts by this author
Nov 24 2001 12:39AM messages near this date
Re: [DOTNET] Programmatically accessing Webform HTML
|
Re: [DOTNET] Aesthetics Question on the CodeDOM
When people use the code dom, do you find yourself using
CodeSnippetStatement and CodeSnippetExpression a lot or do you try and break
it down into the "correct" statements and expressions?
For example, take the following generated code...
return "Hello " + name + "!";
You can use...
CodeSnippetStatement snip = new CodeSnippetStatement(@"return ""Hello ""
+ name + ""!"";");
Or you can use...
CodeMethodReturnStatement st1 = new CodeMethodReturnStatement();
CodeBinaryOperatorExpression op1 = new CodeBinaryOperatorExpression();
CodeBinaryOperatorExpression op2 = new CodeBinaryOperatorExpression();
op1.Left = new CodePrimitiveExpression("Hello ");
op1.Operator = CodeBinaryOperatorType.Add;
op1.Right = op2;
op2.Left = new CodeArgumentReferenceExpression("name");
op2.Operator = CodeBinaryOperatorType.Add;
op2.Right = new CodePrimitiveExpression("!");
st1.Expression = op1;
Granted the second way is significantly more code, but it makes use of the
DOM and can be traversed without having to parse it by hand later (if that
is needed).
Just curious as to what other people do...
Justin
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.
Thread:
Justin Rudd
Dan Green
Justin Rudd
|