static private GetDatabase ( |
||
config | ||
리턴 | MongoDatabase |
public override void Initialize(string name, NameValueCollection config) { this.ApplicationName = config["applicationName"] ?? HostingEnvironment.ApplicationVirtualPath; this.enablePasswordReset = Boolean.Parse(config["enablePasswordReset"] ?? "true"); this.enablePasswordRetrieval = Boolean.Parse(config["enablePasswordRetrieval"] ?? "false"); this.maxInvalidPasswordAttempts = Int32.Parse(config["maxInvalidPasswordAttempts"] ?? "5"); this.minRequiredNonAlphanumericCharacters = Int32.Parse(config["minRequiredNonAlphanumericCharacters"] ?? "1"); this.minRequiredPasswordLength = Int32.Parse(config["minRequiredPasswordLength"] ?? "7"); this.passwordAttemptWindow = Int32.Parse(config["passwordAttemptWindow"] ?? "10"); this.passwordFormat = (MembershipPasswordFormat)Enum.Parse(typeof(MembershipPasswordFormat), config["passwordFormat"] ?? "Hashed"); this.passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"] ?? String.Empty; this.requiresQuestionAndAnswer = Boolean.Parse(config["requiresQuestionAndAnswer"] ?? "false"); this.requiresUniqueEmail = Boolean.Parse(config["requiresUniqueEmail"] ?? "true"); if (this.PasswordFormat == MembershipPasswordFormat.Hashed && this.EnablePasswordRetrieval) { throw new ProviderException("Configured settings are invalid: Hashed passwords cannot be retrieved. Either set the password format to different type, or set enablePasswordRetrieval to false."); } this.mongoCollection = ConnectionHelper.GetDatabase(config).GetCollection(config["collection"] ?? "Users"); this.mongoCollection.EnsureIndex("ApplicationName"); this.mongoCollection.EnsureIndex("ApplicationName", "Email"); this.mongoCollection.EnsureIndex("ApplicationName", "Username"); this.mongoCollection.EnsureIndex(IndexKeys.Ascending("ApplicationName", "Username"), IndexOptions.SetUnique(true).SetName("UniqueApplicationNameUserName")); base.Initialize(name, config); }
public override void Initialize(string name, NameValueCollection config) { this.mongoCollection = ConnectionHelper.GetDatabase(config).GetCollection(config["collection"] ?? "WebEvents"); config.Remove("collection"); config.Remove("connectionString"); config.Remove("database"); base.Initialize(name, config); }
public override void Initialize(string name, NameValueCollection config) { this.ApplicationName = config["applicationName"] ?? HostingEnvironment.ApplicationVirtualPath; this.mongoCollection = ConnectionHelper.GetDatabase(config).GetCollection(config["collection"] ?? "Profiles"); this.mongoCollection.EnsureIndex("ApplicationName"); this.mongoCollection.EnsureIndex("ApplicationName", "IsAnonymous"); this.mongoCollection.EnsureIndex("ApplicationName", "IsAnonymous", "LastActivityDate"); this.mongoCollection.EnsureIndex("ApplicationName", "IsAnonymous", "LastActivityDate", "Username"); this.mongoCollection.EnsureIndex("ApplicationName", "IsAnonymous", "Username"); this.mongoCollection.EnsureIndex("ApplicationName", "LastActivityDate"); this.mongoCollection.EnsureIndex("ApplicationName", "Username"); this.mongoCollection.EnsureIndex("ApplicationName", "Username", "IsAnonymous"); base.Initialize(name, config); }
public override void Initialize(string name, NameValueCollection config) { this.ApplicationName = config["applicationName"] ?? HostingEnvironment.ApplicationVirtualPath; var mongoDatabase = ConnectionHelper.GetDatabase(config); this.rolesMongoCollection = mongoDatabase.GetCollection(config["collection"] ?? "Roles"); this.usersInRolesMongoCollection = mongoDatabase.GetCollection("UsersInRoles"); this.rolesMongoCollection.EnsureIndex("ApplicationName"); this.rolesMongoCollection.EnsureIndex("ApplicationName", "Role"); this.usersInRolesMongoCollection.EnsureIndex("ApplicationName", "Role"); this.usersInRolesMongoCollection.EnsureIndex("ApplicationName", "Username"); this.usersInRolesMongoCollection.EnsureIndex("ApplicationName", "Role", "Username"); base.Initialize(name, config); }
public override void Initialize(string name, NameValueCollection config) { this.mongoCollection = ConnectionHelper.GetDatabase(config).GetCollection(config["collection"] ?? "OutputCache"); this.mongoCollection.EnsureIndex("Key"); base.Initialize(name, config); }
public override void Initialize(string name, NameValueCollection config) { this._SessionStateSection = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection; this._MongoWebSection = ConfigurationManager.GetSection("mongoDbWeb") as MongoDbWebSection; this._MongoCollection = ConnectionHelper.GetDatabase(config) .GetCollection <T>(config["collection"] ?? _MongoWebSection.SessionState.MongoCollectionName); _SessionDataClassMap = new BsonClassMap <T>(); _SessionDataClassMap.AutoMap(); _ApplicationVirtualPathField = MapBsonMember(t => t.ApplicationVirtualPath); _IdField = MapBsonMember(t => t.SessionId); _LockIdField = MapBsonMember(t => t.LockId); _LockedField = MapBsonMember(t => t.Locked); _ExpiresField = MapBsonMember(t => t.Expires); _LockDateField = MapBsonMember(t => t.LockDate); _SessionStateActionsField = MapBsonMember(t => t.SessionStateActions); _SessionItemsField = MapBsonMember(t => t.SessionStateItems); // Ideally, we'd just use the object's bson id - however, serialization gets a bit wonky // when trying to have an Id property which isn't a simple type in the base class // This also provides better backwards compatibility with the old BsonDocument implementation (field names match) this._MongoCollection.EnsureIndex( IndexKeys.Ascending(_ApplicationVirtualPathField, _IdField), IndexOptions.SetUnique(true)); if (_Cache == null) { lock (_CacheGuarantee) { if (_Cache == null) { _Cache = new Cache <string, T> .Builder() { EntryExpiration = new TimeSpan(0, 0, _MongoWebSection.SessionState.MemoryCacheExpireSeconds), MaxEntries = _MongoWebSection.SessionState.MaxInMemoryCachedSessions } .Cache; } } } // Initialise safe mode options. Defaults to Safe Mode=true, fsynch=false, w=0 (replicas to write to before returning) bool safeModeEnabled = true; bool fsync = _MongoWebSection.FSync; if (config["fsync"] != null) { bool.TryParse(config["fsync"], out fsync); } int replicasToWrite = _MongoWebSection.ReplicasToWrite; if ((config["replicasToWrite"] != null) && (!int.TryParse(config["replicasToWrite"], out replicasToWrite))) { throw new ProviderException("replicasToWrite must be a valid integer"); } _SafeMode = SafeMode.Create(safeModeEnabled, fsync, replicasToWrite); base.Initialize(name, config); }