public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IHostApplicationLifetime appLifetime) { AutofacContainer = app.ApplicationServices.GetAutofacRoot(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseExceptionHandlerMiddleware(); MongoConfiguration.Initialize(); var generalSettings = app.ApplicationServices.GetService <GeneralSettings>(); if (generalSettings.SeedData) { var dataInitializer = app.ApplicationServices.GetService <IDataInitializer>(); dataInitializer.SeedAsync(); } app.UseSwagger(); app.UseSwaggerUI(setupAction => { setupAction.SwaggerEndpoint( "/swagger/v1/swagger.json", "RecordMaker API"); setupAction.RoutePrefix = ""; }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); appLifetime.ApplicationStopped.Register(() => ApplicationContainer.Dispose()); }
public void Mongo_Configuration_Supports_Lambda_Syntax_Registration() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(user => user.FirstName).UseAlias("first"))); var alias = MongoConfiguration.GetPropertyAlias(typeof(User), "FirstName"); Assert.Equal("first", alias); }
public override void Init() { MongoConfiguration.Initialize(config => config.For <User>(c => c.ForProperty(u => u.Identity).Ignore())); base.Init(); }
public static void Main(string[] args) { MongoConfiguration.Initialize(); var configuration = GetConfiguration(); CreateHostBuilder(args, configuration).Build().Run(); }
public void Can_Register_TypeConverter() { MongoConfiguration.Initialize(c => c.TypeConverterFor <NonSerializableValueObject, NonSerializableValueObjectTypeConverter>()); IBsonTypeConverter converter = MongoConfiguration.ConfigurationContainer.GetTypeConverterFor(typeof(NonSerializableValueObject)); Assert.Equal(typeof(NonSerializableValueObjectTypeConverter), converter.GetType()); }
static CurrentOperationContainer() { MongoConfiguration.Initialize(c => c.For <CurrentOperationContainer>(a => { a.ForProperty(op => op.Responses).UseAlias("inprog"); })); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } MongoConfiguration.Initialize(); app.UseSwagger(); app.UseCors("MyPolicy"); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); c.RoutePrefix = ""; }); app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(routes => { routes.MapControllerRoute( "default", "/api/{controller}/{action=Index}/{id?}"); }); }
public WorkflowBuilder GetWorkflowBuilder() { MongoConfiguration.Initialize(); ExceptionHandlerService.DiscordConfiguration = this._configuration; return(WorkflowBuilder.Create(this._configuration.Token, this._context, typeof(WatchmanBot).Assembly) .SetDefaultMiddlewares() .AddOnReadyHandlers(builder => { builder .AddHandler(() => Task.Run(() => Log.Information("Bot started and logged in..."))) .AddFromIoC <ConfigurationService>(configurationService => configurationService.InitDefaultConfigurations) .AddFromIoC <CustomCommandsLoader>(customCommandsLoader => customCommandsLoader.InitDefaultCustomCommands) .AddFromIoC <HelpDataCollectorService, HelpDBGeneratorService>((dataCollector, helpService) => () => helpService.FillDatabase(dataCollector.GetCommandsInfo(typeof(WatchmanBot).Assembly))) .AddFromIoC <ResponsesInitService>(responsesService => responsesService.InitNewResponsesFromResources) .AddFromIoC <InitializationService, DiscordServersService>((initService, serversService) => async() => { var stopwatch = Stopwatch.StartNew(); // when bot was offline for less than 1 minutes, it doesn't make sense to init all servers if (WorkflowBuilder.DisconnectedTimes.LastOrDefault() > DateTime.Now.AddMinutes(-1)) { Log.Information("Bot was connected less than 1 minute ago"); return; } await serversService.GetDiscordServersAsync().ForEachAwaitAsync(initService.InitServer); Log.Information(stopwatch.ElapsedMilliseconds.ToString()); }) .AddHandler(() => Task.Run(() => Log.Information("Bot has done every Ready tasks."))); }) .AddOnUserJoinedHandlers(builder => { builder .AddFromIoC <WelcomeUserService>(x => x.WelcomeUser) .AddFromIoC <MutingRejoinedUsersService>(x => x.MuteAgainIfNeeded); }) .AddOnDiscordServerAddedBotHandlers(builder => { builder .AddFromIoC <InitializationService>(initService => initService.InitServer); }) .AddOnWorkflowExceptionHandlers(builder => { builder .AddFromIoC <ExceptionHandlerService>(x => (e, _) => x.LogException(e)) .AddFromIoC <ExceptionHandlerService>(x => x.SendExceptionResponse) .AddFromIoC <ExceptionHandlerService>(x => x.PrintDebugExceptionInfo, onlyOnDebug: true) .AddFromIoC <ExceptionHandlerService>(x => (e, _) => x.SendExceptionToDebugServer(e)); }) .AddOnChannelCreatedHandlers(builder => { builder .AddFromIoC <MuteRoleInitService>(x => x.InitForChannelAsync); }) .AddOnChannelRemovedHandler(builder => { builder .AddFromIoC <ComplaintsChannelService>(x => x.RemoveIfNeededComplaintsChannel); })); }
static FileChunk() { MongoConfiguration.Initialize(container => container.For <FileChunk>(y => { y.ForProperty(j => j.FileID).UseAlias("files_id"); y.ForProperty(j => j.ChunkNumber).UseAlias("n"); y.ForProperty(j => j.BinaryData).UseAlias("data"); })); }
/// <summary> /// Initializes the <see cref="GenericCommandResponse"/> class. /// </summary> static GenericCommandResponse() { MongoConfiguration.Initialize(c => c.For <GenericCommandResponse>(a => { a.ForProperty(auth => auth.Info).UseAlias("info"); }) ); }
public void Mongo_Configuration_Returns_Null_For_Uninitialized_Type_Connection_Strings() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(user => user.FirstName).UseAlias("thisIsntDying"))); var connection = MongoConfiguration.GetConnectionString(typeof(TestProduct)); Assert.Equal(null, connection); }
/// <summary> /// Initializes the <see cref="GetNonceResponse"/> class. /// </summary> static GetNonceResponse() { MongoConfiguration.Initialize(c => c.For <GetNonceResponse>(a => { a.ForProperty(auth => auth.Nonce).UseAlias("nonce"); }) ); }
/// <summary> /// Initializes the <see cref="ForceSyncResponse"/> class. /// </summary> static ForceSyncResponse() { MongoConfiguration.Initialize(c => c.For <ForceSyncResponse>(a => { a.ForProperty(auth => auth.NumberOfFiles).UseAlias("numFiles"); }) ); }
static SubClassedObjectFluentMapped() { MongoConfiguration.Initialize(config => config.For <SubClassedObjectFluentMapped>(c => { c.ForProperty(u => u.ABool).UseAlias("b"); })); }
static ExplainRequest() { MongoConfiguration.Initialize(cfg => cfg.For <ExplainRequest <T> >(y => { y.ForProperty(c => c.Explain).UseAlias("$explain"); y.ForProperty(c => c.Query).UseAlias("query"); })); }
/// <summary> /// Initializes the <see cref="ProfileLevelResponse"/> class. /// </summary> static ProfileLevelResponse() { MongoConfiguration.Initialize(c => c.For <ProfileLevelResponse>(a => { a.ForProperty(p => p.PreviousLevel).UseAlias("was"); a.ForProperty(p => p.SlowOpThreshold).UseAlias("slowms"); })); }
/// <summary> /// Initializes the <see cref="BuildInfoResponse"/> class. /// </summary> static BuildInfoResponse() { MongoConfiguration.Initialize(c => c.For <BuildInfoResponse>(a => { a.ForProperty(auth => auth.Version).UseAlias("version"); a.ForProperty(auth => auth.GitVersion).UseAlias("gitVersion"); a.ForProperty(auth => auth.SystemInformation).UseAlias("sysInfo"); })); }
/// <summary> /// Initializes static members of the <see cref="DbReference{T,TId}"/> class. /// </summary> static DbReference() { MongoConfiguration.Initialize(c => c.For <DbReference <T> >(dbr => { dbr.ForProperty(d => d.Collection).UseAlias("$ref"); dbr.ForProperty(d => d.DatabaseName).UseAlias("$db"); dbr.ForProperty(d => d.Id).UseAlias("$id"); })); }
static SuperClassObjectFluentMapped() { MongoConfiguration.Initialize(config => config.For <SuperClassObjectFluentMapped>(c => { c.ForProperty(u => u.Id).UseAlias("_id"); c.ForProperty(u => u.Title).UseAlias("t"); })); }
static void Main(string[] args) { MongoConfiguration.Initialize(); var autofac = (IComponentContext) new ContainerModule().GetBuilder().Build(); var schedulerService = autofac.Resolve <SchedulerService>(); schedulerService.RunScheduledTasks(); }
public void Mongo_Configuration_Can_Remove_Mapping() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(h => h.LastName).UseAlias("lName"))); //confirm that mapping was set. Assert.Equal("lName", MongoConfiguration.GetPropertyAlias(typeof(User), "LastName")); MongoConfiguration.RemoveMapFor <User>(); //confirm that mapping was unset. Assert.Equal("LastName", MongoConfiguration.GetPropertyAlias(typeof(User), "LastName")); }
static LastErrorResponse() { MongoConfiguration.Initialize(c => c.For <LastErrorResponse>(a => { a.ForProperty(auth => auth.NumberOfErrors).UseAlias("n"); a.ForProperty(auth => auth.Error).UseAlias("err"); a.ForProperty(auth => auth.Code).UseAlias("code"); }) ); }
/// <summary> /// Initializes the <see cref="DeleteIndicesResponse"/> class. /// </summary> static DeleteIndicesResponse() { MongoConfiguration.Initialize(c => c.For <DeleteIndicesResponse>(a => { a.ForProperty(auth => auth.NumberIndexesWas).UseAlias("nIndexesWas"); a.ForProperty(auth => auth.Message).UseAlias("msg"); a.ForProperty(auth => auth.Namespace).UseAlias("ns "); }) ); }
/// <summary> /// Initializes the <see cref="PreviousErrorResponse"/> class. /// </summary> static PreviousErrorResponse() { MongoConfiguration.Initialize(c => c.For <PreviousErrorResponse>(a => { a.ForProperty(auth => auth.NumberOfErrors).UseAlias("n"); a.ForProperty(auth => auth.Error).UseAlias("err"); a.ForProperty(auth => auth.NumberOfOperationsAgo).UseAlias("nPrev"); }) ); }
/// <summary> /// Initializes the <see cref="ExplainPlan"/> class. /// </summary> static ExplainPlan() { MongoConfiguration.Initialize(c => c.For <ExplainPlan>(a => { a.ForProperty(auth => auth.Cursor).UseAlias("cursor"); a.ForProperty(auth => auth.StartKey).UseAlias("startKey"); a.ForProperty(auth => auth.IndexBounds).UseAlias("indexBounds"); }) ); }
public void Collection_Creates_Complex_Index() { using (var db = Mongo.Create(TestHelper.ConnectionString())) { MongoConfiguration.Initialize(j => j.For <TestProduct>(k => k.ForProperty(x => x.Inventory).UseAlias("inv"))); var prods = db.GetCollection <TestProduct>(); prods.CreateIndex(j => new { j.Available, j.Inventory.Count }, "complexIndex", true, IndexOption.Ascending); } }
/// <summary> /// Initializes the <see cref="AuthenticationRequest"/> class. /// </summary> static AuthenticationRequest() { MongoConfiguration.Initialize(c => c.For <AuthenticationRequest>(a => { a.ForProperty(auth => auth.Authenticate).UseAlias("authenticate"); a.ForProperty(auth => auth.Nonce).UseAlias("nonce"); a.ForProperty(auth => auth.User).UseAlias("user"); a.ForProperty(auth => auth.Key).UseAlias("key"); }) ); }
public void Mongo_Configuration_Echos_Unmapped_Property_Names() { MongoConfiguration.Initialize(r => r.For <User>(u => u.ForProperty(user => user.FirstName) .UseAlias("first")) /*.WithProfileNamed("Sample")*/); var first = MongoConfiguration.GetPropertyAlias(typeof(User), "FirstName"); var last = MongoConfiguration.GetPropertyAlias(typeof(User), "LastName"); Assert.Equal("first", first); Assert.Equal("LastName", last); }
static MongoIndex() { MongoConfiguration.Initialize(c => c.For <MongoIndex>(a => { a.ForProperty(auth => auth.Key).UseAlias("key"); a.ForProperty(auth => auth.Namespace).UseAlias("ns"); a.ForProperty(auth => auth.Unique).UseAlias("unique"); a.ForProperty(auth => auth.Name).UseAlias("name"); }) ); }
static CurrentOperationResponse() { MongoConfiguration.Initialize(c => c.For <CurrentOperationResponse>(a => { a.ForProperty(op => op.OperationId).UseAlias("opid"); a.ForProperty(op => op.Operation).UseAlias("op"); a.ForProperty(op => op.Namespace).UseAlias("ns"); a.ForProperty(op => op.SecondsRunning).UseAlias("secs_running"); a.ForProperty(op => op.Description).UseAlias("desc"); }) ); }