/// <summary> /// Initializes a new instance of <see cref="ReflectionBasedDriver" /> with /// type names that are loaded from the specified assembly. /// </summary> /// <param name="providerInvariantName">The Invariant name of a provider.</param> /// <param name="driverAssemblyName">Assembly to load the types from.</param> /// <param name="connectionTypeName">Connection type name.</param> /// <param name="commandTypeName">Command type name.</param> protected ReflectionBasedDriver(string providerInvariantName, string driverAssemblyName, string connectionTypeName, string commandTypeName) { // Try to get the types from an already loaded assembly var connectionType = ReflectHelper.TypeFromAssembly(connectionTypeName, driverAssemblyName, false); var commandType = ReflectHelper.TypeFromAssembly(commandTypeName, driverAssemblyName, false); if (connectionType == null || commandType == null) { #if NETFX if (string.IsNullOrEmpty(providerInvariantName)) { #endif throw new HibernateException(string.Format(ReflectionTypedProviderExceptionMessageTemplate, driverAssemblyName)); #if NETFX } var factory = DbProviderFactories.GetFactory(providerInvariantName); connectionCommandProvider = new DbProviderFactoryDriveConnectionCommandProvider(factory); #endif } else { connectionCommandProvider = new ReflectionDriveConnectionCommandProvider(connectionType, commandType); DriverVersion = connectionType.Assembly.GetName().Version; } }
/// <summary> /// Initializes a new instance of <see cref="ReflectionBasedDriver" /> with /// type names that are loaded from the specified assembly. /// </summary> /// <param name="providerInvariantName">The Invariant name of a provider.</param> /// <param name="driverAssemblyName">Assembly to load the types from.</param> /// <param name="connectionTypeName">Connection type name.</param> /// <param name="commandTypeName">Command type name.</param> /// <seealso cref="DbProviderFactories.GetFactory(string)"/> protected ReflectionBasedDriver(string providerInvariantName, string driverAssemblyName, string connectionTypeName, string commandTypeName) { // Try to get the types from an already loaded assembly var connectionType = ReflectHelper.TypeFromAssembly(connectionTypeName, driverAssemblyName, false); var commandType = ReflectHelper.TypeFromAssembly(commandTypeName, driverAssemblyName, false); if (connectionType == null || commandType == null) { if (string.IsNullOrEmpty(providerInvariantName)) { throw new HibernateException(string.Format(ReflectionTypedProviderExceptionMessageTemplate, driverAssemblyName)); } var factory = DbProviderFactories.GetFactory(providerInvariantName); connectionCommandProvider = new DbProviderFactoryDriveConnectionCommandProvider(factory); } else { connectionCommandProvider = new ReflectionDriveConnectionCommandProvider(connectionType, commandType); } }