Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Data / System / Data / ProviderBase / DbConnectionClosed.cs / 1305376 / DbConnectionClosed.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.ProviderBase { using System; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Threading; using SysTx = System.Transactions; abstract internal class DbConnectionClosed : DbConnectionInternal { // Construct an "empty" connection protected DbConnectionClosed(ConnectionState state, bool hidePassword, bool allowSetConnectionString) : base(state, hidePassword, allowSetConnectionString) { } override public string ServerVersion { get { throw ADP.ClosedConnectionError(); } } override protected void Activate(SysTx.Transaction transaction) { throw ADP.ClosedConnectionError(); } override public DbTransaction BeginTransaction(IsolationLevel il) { throw ADP.ClosedConnectionError(); } override public void ChangeDatabase(string database) { throw ADP.ClosedConnectionError(); } internal override void CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory) { // not much to do here... } override protected void Deactivate() { throw ADP.ClosedConnectionError(); } override public void EnlistTransaction(SysTx.Transaction transaction) { throw ADP.ClosedConnectionError(); } override protected internal DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) { throw ADP.ClosedConnectionError(); } internal override void OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) { // Closed->Connecting: prevent set_ConnectionString during Open if (connectionFactory.SetInnerConnectionFrom(outerConnection, DbConnectionClosedConnecting.SingletonInstance, this)) { DbConnectionInternal openConnection = null; try { connectionFactory.PermissionDemand(outerConnection); openConnection = connectionFactory.GetConnection(outerConnection); } catch { // This should occure for all exceptions, even ADP.UnCatchableExceptions. connectionFactory.SetInnerConnectionTo(outerConnection, this); throw; } if (null == openConnection) { connectionFactory.SetInnerConnectionTo(outerConnection, this); throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull); } connectionFactory.SetInnerConnectionEvent(outerConnection, openConnection); } } } abstract internal class DbConnectionBusy : DbConnectionClosed { protected DbConnectionBusy(ConnectionState state) : base(state, true, false) { } internal override void OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) { throw ADP.ConnectionAlreadyOpen(State); } } sealed internal class DbConnectionClosedBusy : DbConnectionBusy { // Closed Connection, Currently Busy - changing connection string internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedBusy(); // singleton object private DbConnectionClosedBusy() : base(ConnectionState.Closed) { } } sealed internal class DbConnectionOpenBusy : DbConnectionBusy { // Open Connection, Currently Busy - closing connection internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionOpenBusy(); // singleton object private DbConnectionOpenBusy() : base(ConnectionState.Open) { } } sealed internal class DbConnectionClosedConnecting : DbConnectionBusy { // Closed Connection, Currently Connecting internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedConnecting(); // singleton object private DbConnectionClosedConnecting() : base(ConnectionState.Connecting) { } } sealed internal class DbConnectionClosedNeverOpened : DbConnectionClosed { // Closed Connection, Has Never Been Opened internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedNeverOpened(); // singleton object private DbConnectionClosedNeverOpened() : base(ConnectionState.Closed, false, true) { } } sealed internal class DbConnectionClosedPreviouslyOpened : DbConnectionClosed { // Closed Connection, Has Previously Been Opened internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedPreviouslyOpened(); // singleton object private DbConnectionClosedPreviouslyOpened() : base(ConnectionState.Closed, true, true) { } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //[....] //----------------------------------------------------------------------------- namespace System.Data.ProviderBase { using System; using System.ComponentModel; using System.Data; using System.Data.Common; using System.Diagnostics; using System.Globalization; using System.Threading; using SysTx = System.Transactions; abstract internal class DbConnectionClosed : DbConnectionInternal { // Construct an "empty" connection protected DbConnectionClosed(ConnectionState state, bool hidePassword, bool allowSetConnectionString) : base(state, hidePassword, allowSetConnectionString) { } override public string ServerVersion { get { throw ADP.ClosedConnectionError(); } } override protected void Activate(SysTx.Transaction transaction) { throw ADP.ClosedConnectionError(); } override public DbTransaction BeginTransaction(IsolationLevel il) { throw ADP.ClosedConnectionError(); } override public void ChangeDatabase(string database) { throw ADP.ClosedConnectionError(); } internal override void CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory) { // not much to do here... } override protected void Deactivate() { throw ADP.ClosedConnectionError(); } override public void EnlistTransaction(SysTx.Transaction transaction) { throw ADP.ClosedConnectionError(); } override protected internal DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) { throw ADP.ClosedConnectionError(); } internal override void OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) { // Closed->Connecting: prevent set_ConnectionString during Open if (connectionFactory.SetInnerConnectionFrom(outerConnection, DbConnectionClosedConnecting.SingletonInstance, this)) { DbConnectionInternal openConnection = null; try { connectionFactory.PermissionDemand(outerConnection); openConnection = connectionFactory.GetConnection(outerConnection); } catch { // This should occure for all exceptions, even ADP.UnCatchableExceptions. connectionFactory.SetInnerConnectionTo(outerConnection, this); throw; } if (null == openConnection) { connectionFactory.SetInnerConnectionTo(outerConnection, this); throw ADP.InternalConnectionError(ADP.ConnectionError.GetConnectionReturnsNull); } connectionFactory.SetInnerConnectionEvent(outerConnection, openConnection); } } } abstract internal class DbConnectionBusy : DbConnectionClosed { protected DbConnectionBusy(ConnectionState state) : base(state, true, false) { } internal override void OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) { throw ADP.ConnectionAlreadyOpen(State); } } sealed internal class DbConnectionClosedBusy : DbConnectionBusy { // Closed Connection, Currently Busy - changing connection string internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedBusy(); // singleton object private DbConnectionClosedBusy() : base(ConnectionState.Closed) { } } sealed internal class DbConnectionOpenBusy : DbConnectionBusy { // Open Connection, Currently Busy - closing connection internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionOpenBusy(); // singleton object private DbConnectionOpenBusy() : base(ConnectionState.Open) { } } sealed internal class DbConnectionClosedConnecting : DbConnectionBusy { // Closed Connection, Currently Connecting internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedConnecting(); // singleton object private DbConnectionClosedConnecting() : base(ConnectionState.Connecting) { } } sealed internal class DbConnectionClosedNeverOpened : DbConnectionClosed { // Closed Connection, Has Never Been Opened internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedNeverOpened(); // singleton object private DbConnectionClosedNeverOpened() : base(ConnectionState.Closed, false, true) { } } sealed internal class DbConnectionClosedPreviouslyOpened : DbConnectionClosed { // Closed Connection, Has Previously Been Opened internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedPreviouslyOpened(); // singleton object private DbConnectionClosedPreviouslyOpened() : base(ConnectionState.Closed, true, true) { } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RecognizedPhrase.cs
- DateTimeFormatInfoScanner.cs
- LocalizedNameDescriptionPair.cs
- StatusBarAutomationPeer.cs
- StandardCommandToolStripMenuItem.cs
- View.cs
- ApplicationId.cs
- XmlSchemaSimpleType.cs
- UpdateTranslator.cs
- BamlRecords.cs
- HttpListenerRequest.cs
- QueryContinueDragEventArgs.cs
- Convert.cs
- UnauthorizedWebPart.cs
- ActivityDesignerResources.cs
- Rect3D.cs
- DataRowChangeEvent.cs
- QueryReaderSettings.cs
- TreeNodeBinding.cs
- JsonFormatGeneratorStatics.cs
- ClientEventManager.cs
- DataServiceClientException.cs
- CategoryGridEntry.cs
- RSAOAEPKeyExchangeDeformatter.cs
- CompilerHelpers.cs
- PostBackOptions.cs
- Wildcard.cs
- DecimalAnimationBase.cs
- XmlCharCheckingWriter.cs
- TeredoHelper.cs
- KeyInterop.cs
- TreeNodeClickEventArgs.cs
- EventInfo.cs
- Vector3DAnimationBase.cs
- ParallelTimeline.cs
- GeneralTransform2DTo3D.cs
- EmptyEnumerator.cs
- BindValidationContext.cs
- Win32.cs
- HijriCalendar.cs
- ListSortDescription.cs
- Thumb.cs
- URLAttribute.cs
- Attributes.cs
- InputLanguageSource.cs
- WebPartAddingEventArgs.cs
- HttpClientChannel.cs
- SafeSecurityHelper.cs
- codemethodreferenceexpression.cs
- LedgerEntry.cs
- ListItemParagraph.cs
- DbDataAdapter.cs
- AssociationType.cs
- ValidateNames.cs
- PropertyNames.cs
- FormsAuthenticationModule.cs
- PartialList.cs
- StringUtil.cs
- PersonalizationStateQuery.cs
- XmlDataSource.cs
- PrtCap_Public_Simple.cs
- JsonEnumDataContract.cs
- FileDialog_Vista_Interop.cs
- OleDbEnumerator.cs
- XPathDocumentBuilder.cs
- SqlUtil.cs
- ToolStripButton.cs
- DiagnosticTraceSchemas.cs
- AutoCompleteStringCollection.cs
- LightweightCodeGenerator.cs
- XmlSigningNodeWriter.cs
- ButtonBaseAutomationPeer.cs
- WebPartZoneCollection.cs
- Camera.cs
- SessionStateContainer.cs
- SelectionItemPattern.cs
- RectangleConverter.cs
- SerializationException.cs
- DataReceivedEventArgs.cs
- Rule.cs
- SafeHandles.cs
- SqlCaseSimplifier.cs
- ManagementNamedValueCollection.cs
- InvalidOleVariantTypeException.cs
- XamlReaderConstants.cs
- KeyInfo.cs
- PropertyValueEditor.cs
- ToolStripItemDesigner.cs
- Listen.cs
- EnumUnknown.cs
- CopyAttributesAction.cs
- StringTraceRecord.cs
- ColorConvertedBitmap.cs
- RemotingConfigParser.cs
- ListViewDeleteEventArgs.cs
- dsa.cs
- SocketElement.cs
- MobileControlPersister.cs
- MsmqChannelFactoryBase.cs
- PropertyEmitter.cs