Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / Data / System / Data / OleDb / OleDbConnectionFactory.cs / 1 / OleDbConnectionFactory.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// [....]
// [....]
//-----------------------------------------------------------------------------
namespace System.Data.OleDb
{
using System;
using System.Data.Common;
using System.Data.ProviderBase;
using System.Diagnostics;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
sealed internal class OleDbConnectionFactory : DbConnectionFactory {
private OleDbConnectionFactory() : base() {}
// At this time, the OleDb Managed Provider doesn't have any connection pool
// counters because we'd only confuse people with "non-pooled" connections
// that are actually being pooled by the native pooler.
private const string _metaDataXml = ":MetaDataXml";
private const string _defaultMetaDataXml = "defaultMetaDataXml";
public static readonly OleDbConnectionFactory SingletonInstance = new OleDbConnectionFactory();
override public DbProviderFactory ProviderFactory {
get {
return OleDbFactory.Instance;
}
}
override protected DbConnectionInternal CreateConnection(DbConnectionOptions options, object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) {
DbConnectionInternal result = new OleDbConnectionInternal((OleDbConnectionString)options, (OleDbConnection)owningObject);
return result;
}
protected override DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous) {
Debug.Assert(!ADP.IsEmpty(connectionString), "null connectionString");
OleDbConnectionString result = new OleDbConnectionString(connectionString, (null != previous));
return result;
}
override protected DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory){
Debug.Assert (internalConnection != null,"internalConnection may not be null.");
cacheMetaDataFactory = false;
OleDbConnectionInternal oleDbInternalConnection = (OleDbConnectionInternal) internalConnection;
OleDbConnection oleDbOuterConnection = oleDbInternalConnection.Connection;
Debug.Assert(oleDbOuterConnection != null,"outer connection may not be null.");
NameValueCollection settings = (NameValueCollection)PrivilegedConfigurationManager.GetSection("system.data.oledb");
Stream XMLStream =null;
String providerFileName = oleDbOuterConnection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo,ODB.DBPROP_PROVIDERFILENAME) as string;
if (settings != null){
string [] values = null;
string metaDataXML = null;
// first try to get the provider specific xml
// if providerfilename is not supported we can't build the settings key needed to
// get the provider specific XML path
if (providerFileName != null){
metaDataXML = providerFileName + _metaDataXml;
values = settings.GetValues(metaDataXML);
}
// if we did not find provider specific xml see if there is new default xml
if (values == null) {
metaDataXML =_defaultMetaDataXml;
values = settings.GetValues(metaDataXML);
}
// If there is new XML get it
if (values != null) {
XMLStream = ADP.GetXmlStreamFromValues(values,metaDataXML);
}
}
// if the xml was not obtained from machine.config use the embedded XML resource
if (XMLStream == null) {
XMLStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.OleDb.OleDbMetaData.xml");
cacheMetaDataFactory = true;
}
Debug.Assert (XMLStream != null,"XMLstream may not be null.");
// using the ServerVersion as the NormalizedServerVersion. Doing this for two reasons
// 1) The Spec for DBPROP_DBMSVER normalizes the ServerVersion
// 2) for OLE DB its the only game in town
return new OleDbMetaDataFactory (XMLStream,
oleDbInternalConnection.ServerVersion,
oleDbInternalConnection.ServerVersion,
oleDbInternalConnection.GetSchemaRowsetInformation());
}
override protected DbConnectionPoolGroupOptions CreateConnectionPoolGroupOptions(DbConnectionOptions connectionOptions) {
return null;
}
override internal DbConnectionPoolGroupProviderInfo CreateConnectionPoolGroupProviderInfo (DbConnectionOptions connectionOptions) {
return new OleDbConnectionPoolGroupProviderInfo();
}
override internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnection connection) {
OleDbConnection c = (connection as OleDbConnection);
if (null != c) {
return c.PoolGroup;
}
return null;
}
override internal DbConnectionInternal GetInnerConnection(DbConnection connection) {
OleDbConnection c = (connection as OleDbConnection);
if (null != c) {
return c.InnerConnection;
}
return null;
}
override protected int GetObjectId(DbConnection connection) {
OleDbConnection c = (connection as OleDbConnection);
if (null != c) {
return c.ObjectID;
}
return 0;
}
override internal void PermissionDemand(DbConnection outerConnection) {
OleDbConnection c = (outerConnection as OleDbConnection);
if (null != c) {
c.PermissionDemand();
}
}
override internal void SetConnectionPoolGroup(DbConnection outerConnection, DbConnectionPoolGroup poolGroup) {
OleDbConnection c = (outerConnection as OleDbConnection);
if (null != c) {
c.PoolGroup = poolGroup;
}
}
override internal void SetInnerConnectionEvent(DbConnection owningObject, DbConnectionInternal to) {
OleDbConnection c = (owningObject as OleDbConnection);
if (null != c) {
c.SetInnerConnectionEvent(to);
}
}
override internal bool SetInnerConnectionFrom(DbConnection owningObject, DbConnectionInternal to, DbConnectionInternal from) {
OleDbConnection c = (owningObject as OleDbConnection);
if (null != c) {
return c.SetInnerConnectionFrom(to, from);
}
return false;
}
override internal void SetInnerConnectionTo(DbConnection owningObject, DbConnectionInternal to) {
OleDbConnection c = (owningObject as OleDbConnection);
if (null != c) {
c.SetInnerConnectionTo(to);
}
}
}
}
// 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.Common;
using System.Data.ProviderBase;
using System.Diagnostics;
using System.Collections.Specialized;
using System.Configuration;
using System.IO;
sealed internal class OleDbConnectionFactory : DbConnectionFactory {
private OleDbConnectionFactory() : base() {}
// At this time, the OleDb Managed Provider doesn't have any connection pool
// counters because we'd only confuse people with "non-pooled" connections
// that are actually being pooled by the native pooler.
private const string _metaDataXml = ":MetaDataXml";
private const string _defaultMetaDataXml = "defaultMetaDataXml";
public static readonly OleDbConnectionFactory SingletonInstance = new OleDbConnectionFactory();
override public DbProviderFactory ProviderFactory {
get {
return OleDbFactory.Instance;
}
}
override protected DbConnectionInternal CreateConnection(DbConnectionOptions options, object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) {
DbConnectionInternal result = new OleDbConnectionInternal((OleDbConnectionString)options, (OleDbConnection)owningObject);
return result;
}
protected override DbConnectionOptions CreateConnectionOptions(string connectionString, DbConnectionOptions previous) {
Debug.Assert(!ADP.IsEmpty(connectionString), "null connectionString");
OleDbConnectionString result = new OleDbConnectionString(connectionString, (null != previous));
return result;
}
override protected DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory){
Debug.Assert (internalConnection != null,"internalConnection may not be null.");
cacheMetaDataFactory = false;
OleDbConnectionInternal oleDbInternalConnection = (OleDbConnectionInternal) internalConnection;
OleDbConnection oleDbOuterConnection = oleDbInternalConnection.Connection;
Debug.Assert(oleDbOuterConnection != null,"outer connection may not be null.");
NameValueCollection settings = (NameValueCollection)PrivilegedConfigurationManager.GetSection("system.data.oledb");
Stream XMLStream =null;
String providerFileName = oleDbOuterConnection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo,ODB.DBPROP_PROVIDERFILENAME) as string;
if (settings != null){
string [] values = null;
string metaDataXML = null;
// first try to get the provider specific xml
// if providerfilename is not supported we can't build the settings key needed to
// get the provider specific XML path
if (providerFileName != null){
metaDataXML = providerFileName + _metaDataXml;
values = settings.GetValues(metaDataXML);
}
// if we did not find provider specific xml see if there is new default xml
if (values == null) {
metaDataXML =_defaultMetaDataXml;
values = settings.GetValues(metaDataXML);
}
// If there is new XML get it
if (values != null) {
XMLStream = ADP.GetXmlStreamFromValues(values,metaDataXML);
}
}
// if the xml was not obtained from machine.config use the embedded XML resource
if (XMLStream == null) {
XMLStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.OleDb.OleDbMetaData.xml");
cacheMetaDataFactory = true;
}
Debug.Assert (XMLStream != null,"XMLstream may not be null.");
// using the ServerVersion as the NormalizedServerVersion. Doing this for two reasons
// 1) The Spec for DBPROP_DBMSVER normalizes the ServerVersion
// 2) for OLE DB its the only game in town
return new OleDbMetaDataFactory (XMLStream,
oleDbInternalConnection.ServerVersion,
oleDbInternalConnection.ServerVersion,
oleDbInternalConnection.GetSchemaRowsetInformation());
}
override protected DbConnectionPoolGroupOptions CreateConnectionPoolGroupOptions(DbConnectionOptions connectionOptions) {
return null;
}
override internal DbConnectionPoolGroupProviderInfo CreateConnectionPoolGroupProviderInfo (DbConnectionOptions connectionOptions) {
return new OleDbConnectionPoolGroupProviderInfo();
}
override internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnection connection) {
OleDbConnection c = (connection as OleDbConnection);
if (null != c) {
return c.PoolGroup;
}
return null;
}
override internal DbConnectionInternal GetInnerConnection(DbConnection connection) {
OleDbConnection c = (connection as OleDbConnection);
if (null != c) {
return c.InnerConnection;
}
return null;
}
override protected int GetObjectId(DbConnection connection) {
OleDbConnection c = (connection as OleDbConnection);
if (null != c) {
return c.ObjectID;
}
return 0;
}
override internal void PermissionDemand(DbConnection outerConnection) {
OleDbConnection c = (outerConnection as OleDbConnection);
if (null != c) {
c.PermissionDemand();
}
}
override internal void SetConnectionPoolGroup(DbConnection outerConnection, DbConnectionPoolGroup poolGroup) {
OleDbConnection c = (outerConnection as OleDbConnection);
if (null != c) {
c.PoolGroup = poolGroup;
}
}
override internal void SetInnerConnectionEvent(DbConnection owningObject, DbConnectionInternal to) {
OleDbConnection c = (owningObject as OleDbConnection);
if (null != c) {
c.SetInnerConnectionEvent(to);
}
}
override internal bool SetInnerConnectionFrom(DbConnection owningObject, DbConnectionInternal to, DbConnectionInternal from) {
OleDbConnection c = (owningObject as OleDbConnection);
if (null != c) {
return c.SetInnerConnectionFrom(to, from);
}
return false;
}
override internal void SetInnerConnectionTo(DbConnection owningObject, DbConnectionInternal to) {
OleDbConnection c = (owningObject as OleDbConnection);
if (null != c) {
c.SetInnerConnectionTo(to);
}
}
}
}
// 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
- MarkupProperty.cs
- SafeLocalMemHandle.cs
- SiteMapNodeItem.cs
- SerializationSectionGroup.cs
- CursorConverter.cs
- DataGridViewCellPaintingEventArgs.cs
- GraphicsState.cs
- SafeHGlobalHandleCritical.cs
- HttpCacheParams.cs
- ProfileEventArgs.cs
- QuaternionAnimationUsingKeyFrames.cs
- ObjectCloneHelper.cs
- XmlNullResolver.cs
- GridPatternIdentifiers.cs
- UserMapPath.cs
- MenuCommand.cs
- File.cs
- WindowsHyperlink.cs
- Int32Animation.cs
- __Filters.cs
- FontEmbeddingManager.cs
- HtmlElementCollection.cs
- PeerNearMe.cs
- ProtectedConfigurationProviderCollection.cs
- FixedElement.cs
- StaticFileHandler.cs
- RSAPKCS1SignatureFormatter.cs
- PathSegment.cs
- CssClassPropertyAttribute.cs
- CatalogZoneAutoFormat.cs
- RoutedEventArgs.cs
- HMACRIPEMD160.cs
- CornerRadius.cs
- Splitter.cs
- EntryWrittenEventArgs.cs
- XmlCDATASection.cs
- SafeRightsManagementSessionHandle.cs
- TiffBitmapDecoder.cs
- ImmComposition.cs
- ProtocolsSection.cs
- ProcessHostConfigUtils.cs
- VectorCollectionConverter.cs
- MetadataItem.cs
- DesigntimeLicenseContext.cs
- MetadataSerializer.cs
- DrawingAttributesDefaultValueFactory.cs
- PenContexts.cs
- SQlBooleanStorage.cs
- TextElement.cs
- UInt64Converter.cs
- MD5.cs
- cookiecollection.cs
- ComPersistableTypeElementCollection.cs
- ViewGenerator.cs
- CompositeFontInfo.cs
- SerTrace.cs
- DataGridToolTip.cs
- XAMLParseException.cs
- WebPartConnectionsCancelEventArgs.cs
- DirectionalLight.cs
- UseAttributeSetsAction.cs
- GeneralTransformGroup.cs
- PeerPresenceInfo.cs
- SQLBinaryStorage.cs
- WinEventTracker.cs
- XPathNodePointer.cs
- UriTemplateDispatchFormatter.cs
- CustomGrammar.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- TcpHostedTransportConfiguration.cs
- StoreItemCollection.Loader.cs
- ByteStreamMessageEncoder.cs
- ByteStorage.cs
- ToolStripRenderer.cs
- MultiPropertyDescriptorGridEntry.cs
- OletxResourceManager.cs
- LingerOption.cs
- LongSumAggregationOperator.cs
- HtmlInputFile.cs
- HScrollBar.cs
- IgnoreFlushAndCloseStream.cs
- SoundPlayer.cs
- LinearKeyFrames.cs
- xmlfixedPageInfo.cs
- HtmlToClrEventProxy.cs
- PerfCounterSection.cs
- FixedSOMFixedBlock.cs
- CodeGroup.cs
- DetailsViewAutoFormat.cs
- Floater.cs
- Vector3DAnimation.cs
- ColorMap.cs
- BooleanAnimationUsingKeyFrames.cs
- CommunicationObject.cs
- TextRenderer.cs
- GeneralTransform3DCollection.cs
- HebrewNumber.cs
- StyleBamlTreeBuilder.cs
- WorkflowRuntimeService.cs
- XPathParser.cs