public static DbProviderFactory GetFactory(DataRow providerRow) { ADP.CheckArgumentNull(providerRow, "providerRow"); DataColumn column = providerRow.Table.Columns["AssemblyQualifiedName"]; if (column != null) { string str = providerRow[column] as string; if (!ADP.IsEmpty(str)) { Type type = Type.GetType(str); if (null == type) { throw ADP.ConfigProviderNotInstalled(); } FieldInfo field = type.GetField("Instance", BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly); if ((null != field) && field.FieldType.IsSubclassOf(typeof(DbProviderFactory))) { object obj2 = field.GetValue(null); if (obj2 != null) { return((DbProviderFactory)obj2); } } throw ADP.ConfigProviderInvalid(); } } throw ADP.ConfigProviderMissing(); }
static public DbProviderFactory GetFactory(DataRow providerRow) { ADP.CheckArgumentNull(providerRow, "providerRow"); // fail with ConfigProviderMissing rather than ColumnNotInTheTable exception DataColumn column = providerRow.Table.Columns[AssemblyQualifiedName]; if (null != column) { // column value may not be a string string assemblyQualifiedName = providerRow[column] as string; if (!ADP.IsEmpty(assemblyQualifiedName)) { // FXCop is concerned about the following line call to Get Type, // If this code is deemed safe during our security review we should add this warning to our exclusion list. // FXCop Message, pertaining to the call to GetType. // // Secure late-binding methods,System.Data.dll!System.Data.Common.DbProviderFactories.GetFactory(System.Data.DataRow):System.Data.Common.DbProviderFactory, Type providerType = Type.GetType(assemblyQualifiedName); if (null != providerType) { System.Reflection.FieldInfo providerInstance = providerType.GetField(Instance, System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); if (null != providerInstance) { Debug.Assert(providerInstance.IsPublic, "field not public"); Debug.Assert(providerInstance.IsStatic, "field not static"); if (providerInstance.FieldType.IsSubclassOf(typeof(DbProviderFactory))) { object factory = providerInstance.GetValue(null); if (null != factory) { return((DbProviderFactory)factory); } // else throw ConfigProviderInvalid } // else throw ConfigProviderInvalid } throw ADP.ConfigProviderInvalid(); } throw ADP.ConfigProviderNotInstalled(); } // else throw ConfigProviderMissing } throw ADP.ConfigProviderMissing(); }