OleDbReferenceCollection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Data / System / Data / OleDb / OleDbReferenceCollection.cs / 1 / OleDbReferenceCollection.cs

                            //------------------------------------------------------------------------------ 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
// [....]
//----------------------------------------------------------------------------- 
 
namespace System.Data.OleDb {
 
    using System;
    using System.Data;
    using System.Data.Common;
    using System.Data.ProviderBase; 
    using System.Diagnostics;
    using System.Runtime.InteropServices; 
 
    sealed internal class OleDbReferenceCollection : DbReferenceCollection {
        internal const int Closing = 0; 
        internal const int Canceling = -1;

        internal const int CommandTag = 1;
        internal const int DataReaderTag = 2; 

        override public void Add(object value, int tag) { 
            base.AddItem(value, tag); 
        }
 
        override protected bool NotifyItem(int message, int tag, object value) {
            bool canceling = (Canceling == message);
            if (CommandTag == tag) {
                ((OleDbCommand) value).CloseCommandFromConnection(canceling); 
            }
            else if (DataReaderTag == tag) { 
                ((OleDbDataReader) value).CloseReaderFromConnection(canceling); 
            }
            else { 
                Debug.Assert(false, "shouldn't be here");
            }
            return false;   // remove it from the collection
        } 

        override public void Remove(object value) { 
            base.RemoveItem(value); 
        }
 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// [....] 
// [....]
//----------------------------------------------------------------------------- 
 
namespace System.Data.OleDb {
 
    using System;
    using System.Data;
    using System.Data.Common;
    using System.Data.ProviderBase; 
    using System.Diagnostics;
    using System.Runtime.InteropServices; 
 
    sealed internal class OleDbReferenceCollection : DbReferenceCollection {
        internal const int Closing = 0; 
        internal const int Canceling = -1;

        internal const int CommandTag = 1;
        internal const int DataReaderTag = 2; 

        override public void Add(object value, int tag) { 
            base.AddItem(value, tag); 
        }
 
        override protected bool NotifyItem(int message, int tag, object value) {
            bool canceling = (Canceling == message);
            if (CommandTag == tag) {
                ((OleDbCommand) value).CloseCommandFromConnection(canceling); 
            }
            else if (DataReaderTag == tag) { 
                ((OleDbDataReader) value).CloseReaderFromConnection(canceling); 
            }
            else { 
                Debug.Assert(false, "shouldn't be here");
            }
            return false;   // remove it from the collection
        } 

        override public void Remove(object value) { 
            base.RemoveItem(value); 
        }
 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK