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()));
        }
        protected override DbMetaDataFactory CreateMetaDataFactory(DbConnectionInternal internalConnection, out bool cacheMetaDataFactory)
        {
            cacheMetaDataFactory = false;
            OleDbConnectionInternal internal2  = (OleDbConnectionInternal)internalConnection;
            OleDbConnection         connection = internal2.Connection;
            NameValueCollection     section    = (NameValueCollection)System.Configuration.PrivilegedConfigurationManager.GetSection("system.data.oledb");
            Stream xMLStream = null;
            string dataSourcePropertyValue = connection.GetDataSourcePropertyValue(OleDbPropertySetGuid.DataSourceInfo, 0x60) as string;

            if (section != null)
            {
                string[] values = null;
                string   name   = null;
                if (dataSourcePropertyValue != null)
                {
                    name   = dataSourcePropertyValue + ":MetaDataXml";
                    values = section.GetValues(name);
                }
                if (values == null)
                {
                    name   = "defaultMetaDataXml";
                    values = section.GetValues(name);
                }
                if (values != null)
                {
                    xMLStream = ADP.GetXmlStreamFromValues(values, name);
                }
            }
            if (xMLStream == null)
            {
                xMLStream            = Assembly.GetExecutingAssembly().GetManifestResourceStream("System.Data.OleDb.OleDbMetaData.xml");
                cacheMetaDataFactory = true;
            }
            return(new OleDbMetaDataFactory(xMLStream, internal2.ServerVersion, internal2.ServerVersion, internal2.GetSchemaRowsetInformation()));
        }