Exemplo n.º 1
0
        public void Configuration(IAppBuilder app)
        {
            var configuration = new Configuration
            {
                ConnectionString = ConfigurationManager.ConnectionStrings["allors"].ConnectionString,
                ObjectFactory = Config.ObjectFactory
            };
            Config.Default = new Database(configuration);

            // Identity
            app.CreatePerOwinContext<IdentityUserManager>(IdentityUserManager.Create);
            app.CreatePerOwinContext<IdentitySignInManager>(IdentitySignInManager.Create);
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
                Provider = new CookieAuthenticationProvider
                {
                    // Enables the application to validate the security stamp when the user logs in.
                    // This is a security feature which is used when you change a password or add an external login to your account.
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<IdentityUserManager, IdentityUser>(
                        validateInterval: TimeSpan.FromMinutes(30),
                        regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
                }
            });
        }
Exemplo n.º 2
0
        public Investigate()
        {
            this.connectionFactory = new DebugConnectionFactory();
            this.cacheFactory      = new DebugCacheFactory();

            var configuration = new Configuration
            {
                ConnectionString  = ConfigurationManager.ConnectionStrings["allors"].ConnectionString,
                ObjectFactory     = Config.ObjectFactory,
                IsolationLevel    = IsolationLevel.Snapshot,
                CommandTimeout    = 0,
                ConnectionFactory = this.connectionFactory,
                CacheFactory      = this.cacheFactory
            };

            this.database = new Database(configuration);
        }
Exemplo n.º 3
0
        public Database(Configuration configuration)
        {
            this.objectFactory = configuration.ObjectFactory;
            if (!this.objectFactory.MetaPopulation.IsValid)
            {
                throw new ArgumentException("Domain is invalid");
            }

            this.concreteClassesByObjectType = new Dictionary<IObjectType, object>();

            this.connectionString = configuration.ConnectionString;
            this.commandTimeout = configuration.CommandTimeout;
            this.isolationLevel = configuration.IsolationLevel;

            this.sortedUnitRolesByObjectType = new Dictionary<IObjectType, IRoleType[]>();

            this.cache = configuration.CacheFactory.CreateCache(this);

            var connectionStringBuilder = new SqlConnectionStringBuilder(this.ConnectionString);
            var applicationName = connectionStringBuilder.ApplicationName.Trim();
            if (!string.IsNullOrWhiteSpace(applicationName))
            {
                this.id = applicationName;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(connectionStringBuilder.InitialCatalog))
                {
                    this.id = connectionStringBuilder.InitialCatalog.ToLowerInvariant();
                }
                else
                {
                    using (var connection = new SqlConnection(this.ConnectionString))
                    {
                        connection.Open();
                        this.id = connection.Database.ToLowerInvariant();
                    }
                }
            }

            this.schemaName = (configuration.SchemaName ?? "allors").ToLowerInvariant();
            this.objectIds = configuration.ObjectIds ?? new ObjectIdsInteger();
        }