473,385 Members | 1,357 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.

How to get null keyword via Codedom

Hi, I'm writing some CodeDom stuff at the minute. It's great fun but
I've hit a snag. A little bit of the code checks to see whether an
event is null before I fire it. It looks like this...

......Some stuff

CodeConditionStatement ifEventIsntNull = new CodeConditionStatement();
CodeEventReferenceExpression eventRef = new
CodeEventReferenceExpression(new
CodeTypeReferenceExpression("Interation"),
"NewInterationFailure");

CodeSnippetExpression nullExp = new CodeSnippetExpression("null");

CodeBinaryOperatorExpression equalityEx = new
CodeBinaryOperatorExpression(eventRef,
CodeBinaryOperatorType.IdentityInequality, nullExp);
ifEventIsntNull.Condition = equalityEx;

method.Statements.Add(ifEventIsntNull);
The problem is I can't see how to check for null without using the
CodeSnippetExpression (which obviously isn't portable). Anyone throw me
a line?

Cheers,

Tim

Oct 17 '06 #1
1 2654
What about:
new CodeDefaultValueExpression(new CodeTypeReference(typeof(object)))

"Tim Haughton" <ti*********@gmail.comschrieb im Newsbeitrag
news:11*********************@k70g2000cwa.googlegro ups.com...
Hi, I'm writing some CodeDom stuff at the minute. It's great fun but
I've hit a snag. A little bit of the code checks to see whether an
event is null before I fire it. It looks like this...

.....Some stuff

CodeConditionStatement ifEventIsntNull = new CodeConditionStatement();
CodeEventReferenceExpression eventRef = new
CodeEventReferenceExpression(new
CodeTypeReferenceExpression("Interation"),
"NewInterationFailure");

CodeSnippetExpression nullExp = new CodeSnippetExpression("null");

CodeBinaryOperatorExpression equalityEx = new
CodeBinaryOperatorExpression(eventRef,
CodeBinaryOperatorType.IdentityInequality, nullExp);
ifEventIsntNull.Condition = equalityEx;

method.Statements.Add(ifEventIsntNull);
The problem is I can't see how to check for null without using the
CodeSnippetExpression (which obviously isn't portable). Anyone throw me
a line?

Cheers,

Tim

Oct 17 '06 #2

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?...
102
by: junky_fellow | last post by:
Can 0x0 be a valid virtual address in the address space of an application ? If it is valid, then the location pointed by a NULL pointer is also valid and application should not receive "SIGSEGV"...
2
by: Guillaume | last post by:
I don't think I'm the only one with this challenge so… I made code with the CodeDom classes and made code to create a new solution and a new project Now I want to get the codedom code in the new...
1
by: John Livermore | last post by:
Hello, We have an application that uses CodeDom for dynamic in-memory compilation of code. The same code (library) is used by both an ASP.net web site and a Windows Service. The code runs fine...
6
by: moondaddy | last post by:
will CodeDom create XAML windows or just regular windows forms? If so, how to I tell it to create a xaml window instead of a windows form? thanks -- moondaddy@noemail.noemail
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: anchiang | last post by:
Hi All, I have XML: <RegistryResponse status="Success" xmlns="urn:oasis:names:tc:ebxml-regrep:registry:xsd:2.1"> <AdhocQueryResponse xmlns="urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1"> ...
1
by: =?Utf-8?B?QU1lcmNlcg==?= | last post by:
I may have painted myself into a corner with GenerateInMemory=true. My app need a custom user step. Users want to code (sort of - they are not programmers) some refinements to a search...
0
by: thisismykindabyte | last post by:
Hello, I was wondering if anyone might know the easiest way to access static methods through a namespace(MyNamespace) from CodeDom generated code? Basically I have this in my...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.