public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddMediatR(Assembly.GetExecutingAssembly());
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(LoggingBehavior <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(ValidationBehavior <,>));

            services.TryAddTransient <IValidator <SaveMessageCommand>, SaveMessageCommandValidator>();
        }
Beispiel #2
0
 public void ConfigureContainer(ServiceRegistry services)
 {
     services.Scan(s =>
     {
         s.TheCallingAssembly();
         s.AssembliesFromApplicationBaseDirectory(a => a.GetName().Name.Contains("PhotoAlbum"));
         s.WithDefaultConventions();
     });
     services.AddMediatR(Assembly.GetExecutingAssembly());
 }
Beispiel #3
0
        public void ConfigureContainer(ServiceRegistry serviceRegistry)
        {
            serviceRegistry.Scan(scanner =>
            {
                scanner.TheCallingAssembly();
                scanner.WithDefaultConventions();
            });

            serviceRegistry.For(typeof(IPipelineBehavior <,>)).Add(typeof(LoggingBehavior <,>));
            serviceRegistry.For(typeof(IPipelineBehavior <,>)).Add(typeof(ValidationBehavior <,>));

            serviceRegistry.AddMediatR(typeof(Startup));
            serviceRegistry.AddAutoMapper(typeof(MappingProfile));
        }
Beispiel #4
0
        //TODO: configure Lamar "WithDefaultConventions" to remove unneeded registrations
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddSignalR();
            services.AddMvc();

            services.Scan(s => {
                //s.TheCallingAssembly();
                //s.WithDefaultConventions();
                s.AssemblyContainingType(typeof(HomePageCheckHandler));
                s.ConnectImplementationsToTypesClosing(typeof(IRequestHandler <,>));
                s.ConnectImplementationsToTypesClosing(typeof(INotificationHandler <>));
            });

            services.AddSingleton <ICommandsProcessor, CommandsProcessor>();
            services.AddSingleton <ISchedulerService, SchedulerService>();
            services.AddSingleton <IChecksRepository, MemoryCheckRepository>();
            services.AddSingleton <IScheduleRepository, MemoryScheduleRepository>();
            services.AddSingleton <IHostedService, CheckRegistrator>();
            services.AddSingleton <ILoggerService, TextLoggerService>();
            services.AddSingleton <ILogStashService, LogStashService>();
            services.AddSingleton <IHttpRequestService, HttpRequestService>();
            services.AddSingleton <INotificationsService, NotificationsService>();

            services.AddTransient <ISignalRNotificationsService, SignalRNotificationsService>();
            services.AddTransient <IResultHandlingService, ResultHandlingService>();
            services.AddTransient <IUnitTestsProcessorService, UnitTestsProcessorService>();
            services.AddTransient <IWebDriversFactory, SeleniumDriversFactory>();
            services.AddTransient <ITelegramNotificationService, TelegramService>();

            services.AddMediatR(typeof(HomePageCheckHandler).GetTypeInfo().Assembly);

            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(LoggerDecorator <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(CommandResultHandleDecorator <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(SignalRDecorator <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(NotificationsDecorator <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(DataStoreDecorator <,>));
            services.AddTransient(typeof(IPipelineBehavior <,>), typeof(CommandExceptionsDecorator <,>));

            services.Configure <TelegramNotificationSettings>(Configuration.GetSection("TelegramNotificationSettings"));
            services.Configure <LoggerSettings>(Configuration.GetSection("LoggerSettings"));

            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            services.AddAutoMapper(typeof(ChecksMappingProfile));
        }
Beispiel #5
0
        public void ConfigureContainer(ServiceRegistry registry)
        {
            registry.ConfigureInfrastructure();

            registry.ConfigureAppNotifications();
            ConfigureIdentity(registry);

            registry.ConfigureMediatr();
            registry.AddMediatR(typeof(Login).Assembly);

            // Data access.
            var coreDbContextOptions = this.Configuration.DbContextOptions();

            registry.ConfigureDataAccess(coreDbContextOptions);

            registry.ConfigureUserRoleCheckers();
            registry.ConfigureEmailTemplates();
            registry.ConfigureEmailSenders <AuthMessageSender, AuthMessageSender>();

            registry.For <UserContextAccessor>().Use <AppUserContextAccessor>();
            registry.For <UserContext>().Use(ctx => ctx.GetInstance <UserContextAccessor>().GetUserContext());
            registry.For <UserSession>().Use(ctx => ctx.GetInstance <CookieManager>().GetUserSession()).Transient();

            registry.Scan(_ =>
            {
                _.AssemblyContainingType <CoreDbContext>();
                _.AssemblyContainingType <IEntityFileManager>();
                _.AssemblyContainingType <IMediator>();
                _.AssemblyContainingType <BaseDbContext>();

                _.AssemblyContainingType <INotificationManager>();
                _.AssemblyContainingType <ApplicationDbContext>();
                _.AssemblyContainingType <UserRoleChecker>();
                _.AssemblyContainingType <ConversationManagerCollection>();

                _.AddAllTypesOf <IAssemblyBootstrapper>();
                _.AddAllTypesOf(typeof(Register <>));
                _.WithDefaultConventions();
            });

            var container = new Container(registry);

            registry.ConfigureDomainEvents(Assembly.GetExecutingAssembly(), container);
            container.RunAssemblyBootstrapers();
            registry.ConfigureRegisters(container);
        }
Beispiel #6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddControllersWithViews().AddControllersAsServices().AddJsonOptions(x =>
            {
                x.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
                x.JsonSerializerOptions.MaxDepth = 255;
            });

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
            services.AddEntityFrameworkSqlServer();

            services.AddSwaggerGen(c =>
            {
                c.AddServer(new OpenApiServer
                {
                    Url         = "http://localhost:5000",
                    Description = "HTTP endpoint"
                });
                c.AddServer(new OpenApiServer
                {
                    Url         = "https://localhost:5001",
                    Description = "HTTP endpoint with SSL"
                });
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Where Is My Fleet API", Version = "v1"
                });
                c.CustomSchemaIds((t) =>
                {
                    return(t.FullName.Replace("+", ""));
                });
            });

            //var applicationServicesAssembly = Assembly.Load();
            services.AddMediatR(typeof(WhereIsMyFleet.Services.CurrentUserModel).Assembly);
            services.For <IConfiguration>().Use(Configuration);
            services.AddDbContext <WhereIsMyFleetDbContext>(o => o.UseSqlServer(Configuration.GetConnectionString("WhereIsMyFleet")));
            services.SetupRegistries();
        }
Beispiel #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddControllers();

            services.Scan(s =>
            {
                s.TheCallingAssembly();
                s.WithDefaultConventions();
            });

            var assemblies =
                AppDomain
                .CurrentDomain
                .GetAssemblies()
                .Where(s => s.GetName().Name.StartsWith(nameof(Sigantha)))
                .ToArray();

            // Auto Mapper
            services.AddAutoMapper(assemblies);

            // Mediatr
            services.AddMediatR(assemblies);

            services.Scan(scanner =>
            {
                foreach (var assembly in assemblies)
                {
                    scanner.Assembly(assembly);
                }

                scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler <,>));
            });

            // Need to add one for mediatr to see all of them
            services.For <IRequestHandler <TimelineGet.Query, TimelineGet.Result> >().Use <TimelineGet.Handler>();

            services.For <IMediator>().Use <Mediator>().Transient();
            services.For <ServiceFactory>().Use(ctx => ctx.GetInstance);

            // Db Contexts
            services.AddDbContext <SiganthaContext>(ServiceLifetime.Transient);
        }
Beispiel #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureContainer(ServiceRegistry services)
        {
            services.AddControllers();

            services.Scan(s =>
            {
                s.TheCallingAssembly();
                s.WithDefaultConventions();
            });

            var assemblies =
                AppDomain
                .CurrentDomain
                .GetAssemblies()
                .Where(s => s.GetName().Name.StartsWith(nameof(Conglomerate)))
                .ToArray();

            // Auto Mapper
            services.AddAutoMapper(assemblies);

            // Services
            services.For <IIngredientService>().Use <IngredientService>();

            // Repositories
            services.For <IIngredientRepository>().Use <IngredientRepository>();

            // Mediatr
            services.AddMediatR(assemblies);

            services.Scan(scanner =>
            {
                foreach (var assembly in assemblies)
                {
                    scanner.Assembly(assembly);
                }

                scanner.ConnectImplementationsToTypesClosing(typeof(IRequestHandler <,>));
            });

            // For some reason we need to register one of the handlers for Lamar to register all of them
            services.For <IRequestHandler <IngredientGetAll.Query, IList <IngredientGetAll.Ingredient> > >().Use <IngredientGetAll.Handler>();

            services.For <IMediator>().Use <Mediator>().Transient();
            services.For <ServiceFactory>().Use(ctx => ctx.GetInstance);

            // Db Contexts
            services.AddDbContext <SandwichShopContext>(ServiceLifetime.Transient);

            // Hangfire
            services.AddHangfire(configuration => configuration
                                 .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
                                 .UseSimpleAssemblyNameTypeSerializer()
                                 .UseRecommendedSerializerSettings()
                                 .UseStorage(new MySqlStorage(Configuration.GetConnectionString("Hangfire"), new MySqlStorageOptions()
            {
                TransactionIsolationLevel  = IsolationLevel.ReadCommitted,
                QueuePollInterval          = TimeSpan.FromSeconds(1),
                JobExpirationCheckInterval = TimeSpan.FromHours(1),
                CountersAggregateInterval  = TimeSpan.FromMinutes(5),
                PrepareSchemaIfNecessary   = true,
                DashboardJobListLimit      = 50000,
                TransactionTimeout         = TimeSpan.FromMinutes(1),
                TablePrefix = "Hangfire"
            })));

            services.AddHangfireServer(options =>
            {
                // Order determines priority
                options.Queues = new[] { JobQueues.API, JobQueues.DEFAULT };
            });

            services.For <IJobFactory>().Use <JobFactory>();
        }
 public static void ConfigureMediatr(this ServiceRegistry registry)
 {
     registry.AddMediatR(AssembliesWithRequestHandlers.Value);
     registry.For(typeof(IPipelineBehavior <,>)).Add(typeof(SecurityDecorator <,>));
 }