473,395 Members | 1,554 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,395 software developers and data experts.

IDisposable pattern in CodeDom (.net 2)

Hi

I've been trying to find a way of creating the IDisposable pattern using
CodeDom without resorting to literal statements. I can create the
equivalent with a CodeTryCatchFinallyStatement, but it's not nice to look at
especially when you have nested disposable objects, e.g. connection >
command dataAdapter.

I'm probably missing something, so if anyone can point me in the right
direction it would be greatly appreciated.

Also, any idea why CodeBinaryOperatorType doesn't have ValueInequality? It
just seems like such a simple and obvious thing to have.

How I want it...

if ( oracleDataAdapter != null )
{
//Do stuff
}

Instead the code has to look like this (ick!)...

if ( ( oracleDataAdapter == null ) == false )
{
//Do stuff
}

or perhaps (again, ick!)...

if ( ( oracleDataAdapter == null ) )
{
//Do nought
}
else
{
//Do stuff
}

Again, I've probably missed something and even if I haven't, it's no biggy,
but it would be nice to understand why.

Thanks

Glenn

Sep 12 '06 #1
0 890

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

Similar topics

26
by: codymanix | last post by:
Last night I had several thought about RAII and want to discuss a bit. Why doesn't CSharp support destructors in structs? Wouldn't that make RAII possible like in C++? When the struct goes out of...
3
by: Ivan Neganov | last post by:
Hi, I have a custom subclass of System.IO.Stream type. I wonder how to correctly implement the IDisposable pattern in this situation. The parent Stream type apparently uses explicit interface...
5
by: Robert Heuvel | last post by:
Hi, this is what I did: public struct SWaitCursor:IDisposable { public SWaitCursor (int i) { Cursor.Current = Cursors.WaitCursor; } void System.IDisposable.Dispose() { Cursor.Current =...
3
by: Dave | last post by:
I trying to determine the best pattern for designing my business and data layers... Can the instance of the business object eventually cause memory leaks in Example 1? If your business class...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
12
by: Cordell Lawrence \(News Group\) | last post by:
There an ongoing discussion between a colleague and myself about the usefulness of the IDisposable pattern beyond the reclamation of unmanaged resources. The discussion is somewhat lengthy so I...
12
by: Mark Rae | last post by:
Hi, The following code works: HttpWebRequest objRequest = null; try { HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.microsoft.com"); using (HttpWebResponse...
47
by: Hilton | last post by:
Hi, I'm sure I'm simplifying things here, but how about if the GC did this to objects that implement IDisposable: 1. Always Generation 1 (I think that is the correct name) 2. Get aggressive...
4
by: cgarcia0117 | last post by:
For any class I write in C# that has a member variable that implements IDisposable my class implements the IDisposable pattern. I do this to guarantee the reference to the member is explicitly...
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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.