473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

CodeDom VB code generation

I am using the Codedom classes to generate some code. Generally it is
pretty intuitive but I have not been able to determine how to generate the
'not' statement. Specifically I want to be able to generate something like:

if not testexpression then
...
end if

The if is fine it is a codeConditionStatement but I am not sure how to do
the 'not'.

Tim
Nov 20 '05 #1
5 1298
"Tim Bond" <ti*******@rcn.com> schrieb
I am using the Codedom classes to generate some code. Generally it
is pretty intuitive but I have not been able to determine how to
generate the 'not' statement. Specifically I want to be able to
generate something like:

if not testexpression then
...
end if

The if is fine it is a codeConditionStatement but I am not sure how
to do the 'not'.


I've never used CodeDom so far, so there's a high probability that I am
wrong, but maybe it is

New CodeBinaryOperatorExpression( _
TestExpression, _
CodeBinaryOperatorType.ValueEquality, _
New CodePrimitiveExpression(False), _
)

? Does this work?

--
Armin

Nov 20 '05 #2
Hi Tim,

If Armin's BinaryOperator using Equality doesn't do the trick, I'm
thinking you'll have to use a CodeSnippetExpression and supply the "Not" that
way.

Regards,
Fergus
Nov 20 '05 #3
It doesn't actually generate a 'NOT' but it has the same effect - Thanks for
the suggestion

Tim
Nov 20 '05 #4
I thought of this but I wasn't sure how to combine the snippet and the
condition into a single condition. It is logically one statement operating
on another like a function call with a parameter but ther isn't a way to
expand codeDom expressions as part of the snippet.

Fortunately Armin's suggestion - whilst it doesn't generate a not - is
functionally equivalent - near enough.

Thanks Tim

"Fergus Cooney" <fi*****@post.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
Hi Tim,

If Armin's BinaryOperator using Equality doesn't do the trick, I'm
thinking you'll have to use a CodeSnippetExpression and supply the "Not" that way.

Regards,
Fergus

Nov 20 '05 #5
Hi Tim,

This should do the trick. If you know that it won't require brackets,
simpler still

Dim oNotExpr As New CodeSnippetExpression ("Not (" & oExpr.ToString & ")")

Regards,
Fergus
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ron Bullman | last post by:
Hi, I havent been able to find any documentation about @ in the CodeDom context. The problem is when generating C# code from CodeDom it will associate a @-tag with all C# specific types. Why?...
0
by: Aaron A. Anderson | last post by:
I put up a small article comparing code generation with pure CodeDOM and CodeDOM with Refly helping. http://aaronthearchitect.com
0
by: MikeG | last post by:
Hi, I am using codeDom to dynamically produce code objects and would like to extend this to produce aspx page to exploit these and would like advice on the best approach. I currently produce...
0
by: Shawn A. Hall | last post by:
First, I apologize if this isn't the right group to post this question, but I didn't see a newsgroup specific to CodeDom so here I am. On to my question: I am trying to use CodeDom to generate...
0
by: Sherif ElMetainy | last post by:
Hello I am making an application that generates source code. I am facing some problems. 1- How can I generate code that uses the c# 'params' keyword to specify multiple arguments? I tried 2...
3
by: Tapas | last post by:
Hi, Generating a .cs file using CodeDom. It generates the class fine. But i have few queries about class generation. 1. How to create a protected member? By default it generates a private...
1
by: Bragadiru | last post by:
Hi, I can compile dinamically with CodeDOM, but all the dlls have 0.0.0.0 version. How can I set it ?? Thanks for any advice
1
by: Nathan Baulch | last post by:
Is it possible to generate an "as" operator in CodeDom without using a snippet? CodeDom is tedious enough as it is without not having this handy operator. Nathan
2
by: CodeMonkey775 | last post by:
I'm having problems passing a variable to a method which is executed and compiled using CodeDom. The situation is I have a List<CellData> with cells, each containing a formula (like Excel). I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.