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

Re: CodeDom VB code generation by Armin

Armin
Fri Oct 24 10:58:03 CDT 2003

"Tim Bond" <timstacey@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


Re: CodeDom VB code generation by Fergus

Fergus
Fri Oct 24 21:51:02 CDT 2003

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



Re: CodeDom VB code generation by Tim

Tim
Fri Oct 24 22:04:34 CDT 2003

It doesn't actually generate a 'NOT' but it has the same effect - Thanks for
the suggestion

Tim



Re: CodeDom VB code generation by Tim

Tim
Fri Oct 24 22:10:23 CDT 2003

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" <filter1@post.com> wrote in message
news:udjVUMqmDHA.2272@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
>
>



Re: CodeDom VB code generation by Fergus

Fergus
Fri Oct 24 23:32:37 CDT 2003

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