Rebel.Framework.Persistence.NHibernate.ProviderBootstrapper.TryInstall C# (CSharp) Method

TryInstall() public method

public TryInstall ( ) : InstallStatus
return Rebel.Framework.ProviderSupport.InstallStatus
        public override InstallStatus TryInstall()
        {
            switch (_localConfig.Driver)
            {
                case SupportedNHDrivers.MsSqlCe4:
                    using (new WriteLockDisposable(SchemaValidationLocker))
                    {
                        using (var sqlCeEngine = new SqlCeEngine(_configuration.Properties[Environment.ConnectionString]))
                        {
                            if (!sqlCeEngine.Verify())
                            {
                                sqlCeEngine.CreateDatabase();
                            }
                        }
                    }
                    break;
            }

            InstallStatus installStatus;
            try
            {
                var schemaAlreadyValid = ValidateSchema(_configuration);
                if (schemaAlreadyValid) 
                    return new InstallStatus(InstallStatusType.Completed);
                UpdateSchema(_configuration);
                installStatus = new InstallStatus(InstallStatusType.Completed);
            }
            catch (Exception ex)
            {
                installStatus = new InstallStatus(InstallStatusType.TriedAndFailed, ex);
            }
            return installStatus;
        }

Usage Example

        public void NHibernateBootstrapper_Completed()
        {
            var builder = new NHibernateConfigBuilder("data source=:memory:", "unit-tester", SupportedNHDrivers.SqlLite, "thread_static", false);
            var config = builder.BuildConfiguration();
            var boot = new ProviderBootstrapper(config, new ProviderConfigurationSection()
            {
                ConnectionStringKey = "data source=:memory:",
                Driver = SupportedNHDrivers.SqlLite,
                SessionContext = "thread_static"
            }, new FakeFrameworkContext());

            var status = boot.TryInstall();

            Assert.AreEqual(InstallStatusType.Completed, status.StatusType);
        }
All Usage Examples Of Rebel.Framework.Persistence.NHibernate.ProviderBootstrapper::TryInstall