public void Remove(SessionElement session)
 {
     if (BaseIndexOf(session) >= 0)
     {
         BaseRemove(session.Name);
     }
 }
        public static IConnectionProvider NewConnectionProvider(SessionElement settings)
        {
            IConnectionProvider connectionProvider;
            string providerClass = settings.ConnectionProvider;
            if (!string.IsNullOrEmpty(providerClass))
            {
                try
                {
                    connectionProvider = (IConnectionProvider)Activator.CreateInstance(Type.GetType(providerClass));
                }
                catch (Exception e)
                {

                    throw new Exception("Could not instantiate connection provider: " + providerClass, e);
                }
            }
            else if (!string.IsNullOrEmpty(settings.ConnectionString))
            {
                connectionProvider = new DriverConnectionProvider();
            }
            else
            {
                connectionProvider = new UserSuppliedConnectionProvider();
            }
            connectionProvider.Configure(settings);
            return connectionProvider;
        }
Example #3
0
 public virtual void Configure(SessionElement settings)
 {
     dirverSettings = settings;
     // Command timeout, -1
     commandTimeout = settings.CommandTimeOut;
     // Prepare sql enabled, false
     prepareSql = settings.PrepareSqlEnable;
 }
Example #4
0
        private Settings BuildSettings(SessionElement sessionElement)
        {
            Settings settings = new Settings();
            IConnectionProvider connectionProvider = ConnectionProviderFactory.NewConnectionProvider(sessionElement);
            ITransactionFactory transactionFactory = CreateTransactionFactory(sessionElement);
            string releaseModeName = sessionElement.ConnectionReleaseMode;
            ConnectionReleaseMode releaseMode = "auto".Equals(releaseModeName) ? ConnectionReleaseMode.AfterTransaction : ParseConnectionReleaseMode(releaseModeName);
            settings.SessionFactoryName = sessionElement.Name;
            settings.ConnectionReleaseMode = releaseMode;
            // settings.DefaultBatchFetchSize = sessionElement.DefaultBatchFetchSize;
            settings.BatchSize = sessionElement.BatchSize;
            settings.BatcherFactory = new BatcherFactory();// CreateBatcherFactory(sessionElement, settings.BatchSize, connectionProvider);
            string isolationString = sessionElement.IsolationString;
            IsolationLevel isolation = IsolationLevel.Unspecified;

            if (isolationString.Length > 0)
            {
                try
                {
                    isolation = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), isolationString);
                }
                catch
                {
                    throw new Exception("The isolation level of " + isolationString + " is not a valid IsolationLevel.  Please use one of the Member Names from the IsolationLevel.");
                }
            }
            settings.IsolationLevel = isolation;
            settings.ConnectionProvider = connectionProvider;
            settings.TransactionFactory = transactionFactory;
            return settings;
        }
Example #5
0
 // TransactionManagerLookup transactionManagerLookup = TransactionManagerLookupFactory.GetTransactionManagerLookup( properties );
 private static ITransactionFactory CreateTransactionFactory(SessionElement sessionElement)
 {
     return (ITransactionFactory)Activator.CreateInstance(Type.GetType(sessionElement.TransactionFactory));
 }
 /// <summary>
 /// Configures the ConnectionProvider with only the Driver class.
 /// </summary>
 /// <param name="settings"></param>
 /// <remarks>
 /// All other settings of the Connection are the responsibility of the User since they configured
 /// ORM to use a Connection supplied by the User.
 /// </remarks>
 public override void Configure(SessionElement settings)
 {
     ConfigureDriver(settings);
 }
Example #7
0
 public virtual void Configure(SessionElement settings)
 {
     connString = GetNamedConnectionString(settings);
     ConfigureDriver(settings);
 }
Example #8
0
 protected virtual string GetNamedConnectionString(SessionElement settings)
 {
     return settings.ConnectionString;
 }
Example #9
0
 protected virtual void ConfigureDriver(SessionElement settings)
 {
     try
     {
         driver = (IDriver)Activator.CreateInstance(Type.GetType(settings.Driver));
         driver.Configure(settings);
     }
     catch (Exception e)
     {
         throw new Exception("Could not create the driver from " + settings.Driver + ".", e);
     }
 }
 public int IndexOf(SessionElement session)
 {
     return BaseIndexOf(session);
 }
 public void Add(SessionElement session)
 {
     BaseAdd(session);
 }