Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Data / System / Data / ProviderBase / DbConnectionClosed.cs / 1 / 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
- HttpValueCollection.cs
- FrugalMap.cs
- ByteStreamGeometryContext.cs
- UnsafePeerToPeerMethods.cs
- VirtualizedItemProviderWrapper.cs
- DateTimeFormat.cs
- InstallerTypeAttribute.cs
- XmlBinaryReader.cs
- WebHeaderCollection.cs
- AnnotationMap.cs
- TextWriterTraceListener.cs
- _KerberosClient.cs
- StylusButtonCollection.cs
- clipboard.cs
- SizeFConverter.cs
- ListBindingHelper.cs
- ALinqExpressionVisitor.cs
- ComponentManagerBroker.cs
- AxHost.cs
- FilterElement.cs
- ObjectItemConventionAssemblyLoader.cs
- AuthenticationConfig.cs
- _ScatterGatherBuffers.cs
- SvcFileManager.cs
- PartialList.cs
- rsa.cs
- D3DImage.cs
- TraceLevelStore.cs
- ProfileService.cs
- ConsumerConnectionPoint.cs
- FrameworkElement.cs
- CatalogPartChrome.cs
- LabelEditEvent.cs
- CompositionAdorner.cs
- ListViewVirtualItemsSelectionRangeChangedEvent.cs
- ObjectFullSpanRewriter.cs
- UInt32Storage.cs
- VoiceObjectToken.cs
- ResourceType.cs
- DataObjectAttribute.cs
- ExceptionValidationRule.cs
- XmlSchemaIdentityConstraint.cs
- UserPersonalizationStateInfo.cs
- ZoneButton.cs
- Exceptions.cs
- ToolBar.cs
- IntegerValidator.cs
- HttpWebResponse.cs
- Font.cs
- RoleGroupCollection.cs
- PagerSettings.cs
- SynchronousReceiveBehavior.cs
- DataGridViewCellCancelEventArgs.cs
- TabItem.cs
- NetCodeGroup.cs
- TypeElement.cs
- TableSectionStyle.cs
- precedingsibling.cs
- FixedDSBuilder.cs
- DBBindings.cs
- ShaderEffect.cs
- CallTemplateAction.cs
- EmptyControlCollection.cs
- LinkUtilities.cs
- TraceHandler.cs
- SmiXetterAccessMap.cs
- Point3DCollectionConverter.cs
- altserialization.cs
- CodeStatementCollection.cs
- ModuleElement.cs
- Header.cs
- DbSource.cs
- SqlDataSourceView.cs
- FieldInfo.cs
- OptionUsage.cs
- SoapFormatExtensions.cs
- __Filters.cs
- X509ChainElement.cs
- DetailsViewDeletedEventArgs.cs
- AutoGeneratedField.cs
- XPathAxisIterator.cs
- IntranetCredentialPolicy.cs
- WindowsIdentity.cs
- DataSourceProvider.cs
- DetailsViewModeEventArgs.cs
- DecimalAnimationBase.cs
- cryptoapiTransform.cs
- RuntimeArgumentHandle.cs
- ToolStripItemCollection.cs
- GlobalizationSection.cs
- XmlSchemaValidationException.cs
- UriScheme.cs
- NavigateEvent.cs
- CodeExpressionStatement.cs
- TableAdapterManagerNameHandler.cs
- ParameterModifier.cs
- CriticalExceptions.cs
- CodeIdentifiers.cs
- SharedMemory.cs
- WebPartAddingEventArgs.cs