protected override void BeginProcessing()
        {
            var storeSettings = StoreSettings.DefaultSettings();

            storeSettings.ConnectionString            = ConnectionString ?? storeSettings.ConnectionString;
            storeSettings.Database                    = Database ?? storeSettings.Database;
            storeSettings.ClientCollection            = ClientCollection ?? storeSettings.ClientCollection;
            storeSettings.ScopeCollection             = ScopeCollection ?? storeSettings.ScopeCollection;
            storeSettings.ConsentCollection           = ConsentCollection ?? storeSettings.ConsentCollection;
            storeSettings.AuthorizationCodeCollection = AuthorizationCodeCollection ?? storeSettings.AuthorizationCodeCollection;
            storeSettings.RefreshTokenCollection      = RefreshTokenCollection ?? storeSettings.RefreshTokenCollection;
            storeSettings.TokenHandleCollection       = TokenHandleCollection ?? storeSettings.TokenHandleCollection;
            CanCreateDatabase(storeSettings);

            var serviceFactory = new ServiceFactory(null, storeSettings);

            serviceFactory.Register(new Registration <IMongoClient>(new MongoClient(storeSettings.ConnectionString)));
            var factory = new Factory(storeSettings, serviceFactory, new AdminServiceRegistry());

            _adminService        = factory.Resolve <IAdminService>();
            _tokenCleanupService = factory.Resolve <ICleanupExpiredTokens>();
            _scopeStore          = factory.Resolve <IScopeStore>();
            base.BeginProcessing();
        }
 protected override void BeginProcessing()
 {
     var storeSettings = StoreSettings.DefaultSettings();
     storeSettings.ConnectionString = ConnectionString ?? storeSettings.ConnectionString;
     storeSettings.Database = Database ?? storeSettings.Database;
     storeSettings.ClientCollection = ClientCollection ?? storeSettings.ClientCollection;
     storeSettings.ScopeCollection = ScopeCollection ?? storeSettings.ScopeCollection;
     storeSettings.ConsentCollection = ConsentCollection ?? storeSettings.ConsentCollection;
     storeSettings.AuthorizationCodeCollection = AuthorizationCodeCollection ?? storeSettings.AuthorizationCodeCollection;
     storeSettings.RefreshTokenCollection = RefreshTokenCollection ?? storeSettings.RefreshTokenCollection;
     storeSettings.TokenHandleCollection = TokenHandleCollection ?? storeSettings.TokenHandleCollection;
     CanCreateDatabase(storeSettings);
     
     var serviceFactory = new ServiceFactory(null, storeSettings);
     var factory = new Factory(serviceFactory, new AdminServiceRegistry());
     _adminService = factory.Resolve<IAdminService>();
     _tokenCleanupService = factory.Resolve<ICleanupExpiredTokens>();
     _scopeStore = factory.Resolve<IScopeStore>();
     base.BeginProcessing();
 }