public static IServiceCollection AddSmashLeagueData(
            this IServiceCollection services,
            Action<SmashLeagueDataOptions> setup)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            if (setup == null)
            {
                throw new ArgumentNullException(nameof(setup));
            }

            var dataOptions = new SmashLeagueDataOptions();
            setup(dataOptions);

            services.AddEntityFramework()
                .AddSqlServer()
                .AddDbContext<SmashLeagueDbContext>(options =>
                {
                    options.UseSqlServer(dataOptions.ConnectionString);
                });

            services.AddIdentity<ApplicationUser, IdentityRole>()
                .AddEntityFrameworkStores<SmashLeagueDbContext>()
                .AddDefaultTokenProviders();

            services.AddTransient<ApplicationUserManager>();
            services.AddTransient<SmashLeagueDbInitializer>();

            return services;
        }
        public static IServiceCollection AddOrchardMvc(this IServiceCollection services)
        {
            services
                .AddMvcCore(options =>
                {
                    options.Filters.Add(new ModelBinderAccessorFilter());
                    options.Conventions.Add(new ModuleAreaRouteConstraintConvention());
                    options.ModelBinders.Insert(0, new CheckMarkModelBinder());
                })
                .AddViews()
                .AddViewLocalization()
                .AddRazorViewEngine()
                .AddJsonFormatters();

            services.AddScoped<IModelUpdaterAccessor, LocalModelBinderAccessor>();
            services.AddTransient<IFilterProvider, DependencyFilterProvider>();
            services.AddTransient<IMvcRazorHost, TagHelperMvcRazorHost>();

            services.AddScoped<IAssemblyProvider, OrchardMvcAssemblyProvider>();

            services.AddSingleton<ICompilationService, DefaultRoslynCompilationService>();

            services.Configure<RazorViewEngineOptions>(options =>
            {
                var expander = new ModuleViewLocationExpander();
                options.ViewLocationExpanders.Add(expander);
            });
            return services;
        }
Example #3
0
 public static void AddStatementProcessing(this IServiceCollection services)
 {
     services.AddTransient<IBankAccountStatementProcessor, BankAccountStatementProcessor>();
     services.AddTransient<IBankAccountStatementParser, SberbankStatementParser>();
     services.AddTransient<IBankAccountStatementParser, TinkoffBankStatementParser>();
     services.AddTransient<AggregateStatementParser>();
 }
 public static void ConfigureApplicationDataAccess(this IServiceCollection services, string redisConnectionString)
 {
     services.AddSingleton(serviceProvider =>
         ConnectionMultiplexer.Connect(redisConnectionString));
     services.AddTransient<IShortUrlRepository, ShortUrlRepository>();
     services.AddTransient<IUserRepository, UserRepository>();
 }
 public static IServiceCollection AddDapperApplicationBuilder(this IServiceCollection services)
 {
     services.AddTransient(provider =>
     {
         var conn = provider.GetService<SqlConnection>();
         var userStore = new UserStore(conn);
         var repo = new RepositoryOptions<User>
         {
             UserStore = userStore,
             UserEmailStore = new UserEmailStore(conn),
             UserLockoutStore = new UserLockoutStore(conn),
             UserLoginStore = new UserLoginStore(conn),
             UserPasswordStore = new UserPasswordStore(conn),
             UserPropertyStore = new UserPropertyStore(conn),
             UserRoleStore = new UserRoleStore(conn),
             UserTokenStore = new UserUpdateTokenStore(conn)
         };
         return new UserManager<User>(repo, provider.GetService<IEmailService>(),
             provider.GetService<ILogger<UserManager<User>>>(), TimeSpan.FromDays(1));
     });
     services.AddTransient(
         provider =>
         {
             var manager = provider.GetService<UserManager<User>>();
             return new LoginManager<User>(provider.GetService<UserManager<User>>(),
                 provider.GetService<ILogger<LoginManager<User>>>(),
                 new LoginManagerOptions<User>
                 {
                     ClaimsProvider = new ClaimsProvider<User>(manager, new ClaimTypesOptions())
                 });
         });
     return services;
 }
        public static IServiceCollection AddOrchardMvc(this IServiceCollection services)
        {
            services
                .AddMvcCore(options =>
                {
                    options.Filters.Add(new ModelBinderAccessorFilter());
                    options.Filters.Add(typeof(AutoValidateAntiforgeryTokenAuthorizationFilter));
                    options.ModelBinderProviders.Insert(0, new CheckMarkModelBinderProvider());
                })
                .AddViews()
                .AddViewLocalization()
                .AddRazorViewEngine()
                .AddJsonFormatters();

            services.AddScoped<IModelUpdaterAccessor, LocalModelBinderAccessor>();
            services.AddTransient<IFilterProvider, DependencyFilterProvider>();
            services.AddTransient<IApplicationModelProvider, ModuleAreaRouteConstraintApplicationModelProvider>();

            services.Configure<RazorViewEngineOptions>(configureOptions: options =>
            {
                var expander = new ModuleViewLocationExpander();
                options.ViewLocationExpanders.Add(expander);

                var extensionLibraryService = services.BuildServiceProvider().GetService<IExtensionLibraryService>();
                ((List<MetadataReference>)options.AdditionalCompilationReferences).AddRange(extensionLibraryService.MetadataReferences());
            });

            return services;
        }
        public static void AddBrickPile(this IServiceCollection services)
        {
            _serviceProvider = services.BuildServiceProvider();

            services.AddMvc().ConfigureApplicationPartManager(manager =>
            {
                var feature = new ControllerFeature();
                manager.PopulateFeature(feature);
                services.AddSingleton<IControllerMapper>(new ControllerMapper(feature));
            });

            services.AddRouting(options =>
            {
                options.AppendTrailingSlash = true;
                options.LowercaseUrls = true;
            });

            services.Configure<MvcOptions>(options =>
            {
                options.ModelBinderProviders.Insert(0, new DefaultModelBinderProvider(DocumentStore));
                options.Filters.Add(typeof(PublishedFilterAttribute), 1);
                options.Filters.Add(typeof(AuthorizeFilterAttribute), 2);
            });

            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            services.AddSingleton(DocumentStore);
            services.AddTransient<IRouteResolverTrie>(provider => new RouteResolverTrie(provider.GetService<IDocumentStore>()));
            services.AddTransient<IBricsContextAccessor>(provider => new BricsContextAccessor(provider.GetService<IHttpContextAccessor>(), provider.GetService<IDocumentStore>()));
        }
Example #8
0
        public static IServiceCollection AddSmidge(this IServiceCollection services)
        {
            //services.AddNodeServices(NodeHostingModel.Http);

            services.AddTransient<IConfigureOptions<SmidgeOptions>, SmidgeOptionsSetup>();
            services.AddTransient<IConfigureOptions<Bundles>, BundlesSetup>();
            services.AddSingleton<PreProcessPipelineFactory>();
            services.AddSingleton<BundleManager>();
            services.AddSingleton<FileSystemHelper>();
            services.AddSingleton<PreProcessManager>();
            services.AddSingleton<ISmidgeConfig, SmidgeConfig>();
            services.AddScoped<SmidgeContext>();
            services.AddScoped<SmidgeHelper>();
            services.AddSingleton<IUrlManager, DefaultUrlManager>();
            services.AddSingleton<IHasher, Crc32Hasher>();

            //pre-processors
            services.AddSingleton<IPreProcessor, JsMin>();
            services.AddSingleton<IPreProcessor, CssMinifier>();
            //services.AddSingleton<IPreProcessor, NodeMinifier>();
            services.AddScoped<IPreProcessor, CssImportProcessor>();
            services.AddScoped<IPreProcessor, CssUrlProcessor>();


            //Add the controller models as DI services - these get auto created for model binding
            services.AddTransient<BundleModel>();
            services.AddTransient<CompositeFileModel>();

            return services;
        }
 public static void AddRsxBoxEmailWebApiAppService(this IServiceCollection services)
 {
     services.AddTransient<IEmailManager<EmailTemplate, int>, InMemoryEmailManager>();
     services.AddTransient<IEmailTemplateManager<EmailTemplate, int>, InMemoryEmailTemplateManager<EmailTemplate>>();
     services.AddTransient<IEmailSender<EmailTemplate>, InMemoryEmailSender<EmailTemplate>>();
     services.AddTransient<SmtpClient>();
 }
 private static void AddUserCommandsRegistrations(this IServiceCollection serviceCollection)
 {
     serviceCollection.AddTransient<ICanExecuteRequest<CreateUserRequest, User>, CreateUserCommand>();
     serviceCollection.AddTransient<ICanExecuteRequest<GetUserRequest, User>, GetUserCommand>();
     serviceCollection.AddTransient<ICanExecuteRequest<CheckIfUserExistsRequest, bool>,CheckIfUserExistsCommand>();
     serviceCollection.AddTransient<ICanExecuteRequest<GetUserByIdRequest, User>, GetUserByIdCommand>();
 }
    public static IServiceCollection AddRaygun(this IServiceCollection services, IConfiguration configuration, RaygunMiddlewareSettings middlewareSettings)
    {
      services.Configure<RaygunSettings>(configuration.GetSection("RaygunSettings"));

      services.AddTransient(_ => middlewareSettings.ClientProvider ?? new DefaultRaygunAspNetCoreClientProvider());
      services.AddTransient(_ => middlewareSettings);

      return services;
    }
Example #12
0
        public static IServiceCollection AddCoreValidators(this IServiceCollection services)
        {
            services.AddTransient<ScopeSecretValidator>();
            services.AddTransient<ScopeValidator>();
            services.AddTransient<CustomGrantValidator>();
            services.AddTransient<ClientSecretValidator>();
            services.AddTransient<BearerTokenUsageValidator>();

            return services;
        }
 public static IServiceCollection AddHtmlLocalization(this IServiceCollection services)
 {
     services.AddSingleton<IHtmlLocalizerFactory, HtmlLocalizerFactory>();
     services.AddTransient(typeof(IHtmlLocalizer<>), typeof(HtmlLocalizer<>));
     services.AddTransient(typeof(IViewLocalizer), typeof(ViewLocalizer));
     if (!services.Any(sd => sd.ServiceType == typeof(IHtmlEncoder)))
     {
         services.AddInstance<IHtmlEncoder>(HtmlEncoder.Default);
     }
     return services.AddLocalization();
 }
        public static void AddSwagger(
            this IServiceCollection serviceCollection,
            Action<SwaggerOptions> configure = null)
        {
            serviceCollection.Configure<MvcOptions>(c =>
                c.Conventions.Add(new SwaggerApplicationConvention()));

            serviceCollection.Configure(configure ?? ((options) => {}));

            serviceCollection.AddTransient(GetSchemaRegistry);
            serviceCollection.AddTransient(GetSwaggerProvider);
        }
        /// <summary>
        /// Adds the MVC widgets services to the services collection.
        /// </summary>
        /// <param name="services">The collection of services.</param>
        /// <returns>The collection of services.</returns>
        public static IServiceCollection AddMvcWidgets(this IServiceCollection services)
        {
            services.AddSingleton<IWidgetSelector, DefaultWidgetSelector>();
            services.AddSingleton<IWidgetActivator, DefaultWidgetActivator>();
            services.AddSingleton<IWidgetDescriptorCollectionProvider, DefaultWidgetDescriptorCollectionProvider>();
            services.AddSingleton<IWidgetInvokerFactory, DefaultWidgetInvokerFactory>();
            services.AddSingleton<IWidgetArgumentBinder, DefaultWidgetArgumentBinder>();

            services.AddTransient<IWidgetDescriptorProvider, DefaultWidgetDescriptorProvider>();
            services.AddTransient<IWidgetHelper, DefaultWidgetHelper>();

            return services;
        }
 public static void ConfigureApplicationServices(this IServiceCollection services, string digitalBiblePlatformApiKey, string googleMapsApiKey)
 {
     services.AddTransient<IBibleMetadataService, BibleMetadataService>();
     services.AddTransient<IContentService>(serviceProvider =>
         new DigitalBiblePlatformContentService(
             serviceProvider.GetRequiredService<IUserService>(),
             serviceProvider.GetRequiredService<IBibleMetadataService>(),
             digitalBiblePlatformApiKey));
     services.AddTransient<IShortUrlService, ShortUrlService>();
     services.AddTransient<ITimeService>(serviceProvider =>
         new TimeService(googleMapsApiKey));
     services.AddTransient<IUserService, UserService>();
 }
        public static IServiceCollection AddMapBuilding(
            this IServiceCollection services)
        {
            services.AddTransient<IDirectionPicker>(
                s => new DirectionPicker(
                    s.GetService<DungeonParameters>().TwistFactor));

            services.AddTransient<IList<IMapBuilderCommand>>(s => GenerateCommands(s));
            services.AddScoped<IMapConverter, MapConverter>();
            services.AddScoped<IMapBuilder, MapBuilder>();

            return services;
        }
        public static IServiceCollection AddCloudscribeCore(this IServiceCollection services, IConfigurationRoot configuration)
        {
            services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            services.Configure<MultiTenantOptions>(configuration.GetSection("MultiTenantOptions"));
            services.Configure<SmtpOptions>(configuration.GetSection("SmtpOptions"));
            services.Configure<SiteConfigOptions>(configuration.GetSection("SiteConfigOptions"));
            services.Configure<UIOptions>(configuration.GetSection("UIOptions"));
            services.Configure<CkeditorOptions>(configuration.GetSection("CkeditorOptions"));
            services.Configure<CachingSiteResolverOptions>(configuration.GetSection("CachingSiteResolverOptions"));
            
           
            //services.AddMultitenancy<SiteSettings, SiteResolver>();
            
            services.AddMultitenancy<SiteContext, CachingSiteResolver>();
            services.AddScoped<CacheHelper, CacheHelper>();
            services.AddScoped<SiteManager, SiteManager>();
            services.AddScoped<GeoDataManager, GeoDataManager>();
            services.AddScoped<SystemInfoManager, SystemInfoManager>();
            services.AddScoped<IpAddressTracker, IpAddressTracker>();

            services.AddScoped<SiteDataProtector>();
            // timezone localization from NodaTime
            services.AddCloudscribeCommmon();
            services.AddScoped<ITimeZoneIdResolver, RequestTimeZoneIdResolver>();

            services.AddCloudscribePagination();

            services.AddScoped<IVersionProviderFactory, VersionProviderFactory>();
            services.AddScoped<IVersionProvider, CloudscribeCoreVersionProvider>();
            
            services.AddTransient<ISiteMessageEmailSender, SiteEmailMessageSender>();
            //services.AddTransient<ISiteMessageEmailSender, FakeSiteEmailSender>();
            
            services.AddTransient<ISmsSender, SiteSmsSender>();

            services.TryAddSingleton<IThemeListBuilder, SiteThemeListBuilder>();
            //services.AddSingleton<IRazorViewEngine, CoreViewEngine>();
            services.TryAddScoped<ViewRenderer, ViewRenderer>();

            services.AddSingleton<IOptions<NavigationOptions>, SiteNavigationOptionsResolver>();
            services.AddScoped<ITreeCacheKeyResolver, SiteNavigationCacheKeyResolver>();
            services.AddScoped<INodeUrlPrefixProvider, FolderTenantNodeUrlPrefixProvider>();
            services.AddCloudscribeNavigation(configuration);

            services.AddCloudscribeIdentity();

            return services;
        }
 public static IInversionContainer setupMas(this IInversionContainer container, MasConfiguration config = null) {
     config = config ?? new MasConfiguration();
     var processrepository = config.ProcessRepositoryType ?? typeof (DefaultMasProcessRepository);
     container.AddTransient("mas.model", typeof (MasModel));
     container.AddSingleton("mas.config",typeof(MasConfiguration), config);
     container.ensureService<IMasProcessRepository>( processrepository, "mas.repository.transient");
     container.ensureService<IMasProcessStarter,DefaultMasProcessStarter>("mas.process.starter.transient");
     container.AddTransient("mas.main-controller", typeof (MasController));
     var repositorysetupprovider =
         processrepository.getFirstAttribute<SetupProviderAttribute>().Type.create<IMasSetupProvider>();
     if(null!=repositorysetupprovider) {
         repositorysetupprovider.Execute(container,config);
     }
     return container;
 }
        public static IServiceCollection AddCustomPageCore(this IServiceCollection serviceCollection)
        {
            serviceCollection.AddTransient<IWidgetHarvester, WidgetHarvester>();
            serviceCollection.AddInstance<IModule>(new CustomModule());

            return serviceCollection;
        }
        public static IServiceCollection AddMapPainting(
            this IServiceCollection services)
        {
            services.AddTransient<IMapPainter, ConsolePainter>();

            return services;
        }
        public static IServiceCollection AddHostCore(this IServiceCollection services)
        {
            services.AddTransient<IOrchardHost, DefaultOrchardHost>();
            {
                services.AddSingleton<IShellSettingsManager, ShellSettingsManager>();

                services.AddSingleton<IShellContextFactory, ShellContextFactory>();
                {
                    services.AddSingleton<ICompositionStrategy, CompositionStrategy>();
                    {
                        services.AddSingleton<IOrchardLibraryManager, OrchardLibraryManager>();
                        services.AddSingleton<IExtensionManager, ExtensionManager>();
                        {
                            services.AddSingleton<IExtensionAssemblyLoader, ExtensionAssemblyLoader>();

                            services.AddSingleton<IExtensionHarvester, ExtensionHarvester>();
                            services.AddSingleton<IExtensionFolders, CoreModuleFolders>();
                            services.AddSingleton<IExtensionFolders, ModuleFolders>();

                            services.AddSingleton<IExtensionLoader, CoreExtensionLoader>();
                            services.AddSingleton<IExtensionLoader, DynamicExtensionLoader>();
                        }
                    }

                    services.AddSingleton<IShellContainerFactory, ShellContainerFactory>();
                }
            }

            return services;
        }
        public static IIdentityServerBuilder AddIdentityServer(this IServiceCollection services, Action<IdentityServerOptions> setupAction = null)
        {
            services.AddAuthentication();

            var options = new IdentityServerOptions();

            if (setupAction != null)
            {
                setupAction(options);
            }

            services.AddInstance(options);
            services.AddTransient<IdentityServerContext>();

            services.AddEndpoints(options.Endpoints);
            services.AddCoreValidators();
            services.AddPluggableValidators();
            services.AddResponseGenerators();

            services.AddSecretParsers();
            services.AddSecretValidators();

            services.AddInMemoryTransientStores();
            services.AddCoreServices();
            services.AddHostServices();

            return new IdentityServerBuilder(services);
        }
        public static IServiceCollection AddHostCore(this IServiceCollection services)
        {
            services.AddTransient<IOrchardHost, DefaultOrchardHost>();
            {
                services.AddSingleton<IShellSettingsManager, ShellSettingsManager>();

                services.AddSingleton<IShellContextFactory, ShellContextFactory>();
                {
                    services.AddSingleton<ICompositionStrategy, CompositionStrategy>();
                    {
                        services.AddSingleton<IOrchardLibraryManager, OrchardLibraryManager>();
                        services.AddSingleton<IExtensionManager, ExtensionManager>();
                        {
                            services.AddSingleton<IExtensionAssemblyLoader, ExtensionAssemblyLoader>();

                            services.AddSingleton<IExtensionHarvester, ExtensionHarvester>();

                            services.TryAddEnumerable(
                                ServiceDescriptor.Transient<IConfigureOptions<ExtensionHarvestingOptions>, ExtensionHarvestingOptionsSetup>());
                            services.AddSingleton<IExtensionLocator, ExtensionLocator>();

                            services.AddSingleton<IExtensionLoader, CoreExtensionLoader>();
                            services.AddSingleton<IExtensionLoader, DynamicExtensionLoader>();
                        }
                    }

                    services.AddSingleton<IShellContainerFactory, ShellContainerFactory>();
                }
            }

            return services;
        }
        public static IServiceCollection AddEndpoints(this IServiceCollection services, EndpointOptions endpoints)
        {
            var map = new Dictionary<string, Type>();
            if (endpoints.EnableTokenEndpoint)
            {
                map.Add(Constants.RoutePaths.Oidc.Token, typeof(TokenEndpoint));
            }
            if (endpoints.EnableDiscoveryEndpoint)
            {
                map.Add(Constants.RoutePaths.Oidc.DiscoveryConfiguration, typeof(DiscoveryEndpoint));
            }
            if (endpoints.EnableUserInfoEndpoint)
            {
                map.Add(Constants.RoutePaths.Oidc.UserInfo, typeof(UserInfoEndpoint));
            }
            if (endpoints.EnableIntrospectionEndpoint)
            {
                map.Add(Constants.RoutePaths.Oidc.Introspection, typeof(IntrospectionEndpoint));
            }
            if (endpoints.EnableAuthorizeEndpoint)
            {
                map.Add(Constants.RoutePaths.Oidc.Authorize, typeof(AuthorizeEndpoint));
            }

            services.AddInstance<IEndpointRouter>(new EndpointRouter(map));
            foreach (var item in map)
            {
                services.AddTransient(item.Value);
            }

            return services;
        }
        public static void AddNHibernateSessionFactory(this IServiceCollection services)
        {
            // By default NHibernate looks for hibernate.cfg.xml
            // otherwise for Web it will fallback to web.config
            // we got one under wwwroot/web.config
            Configuration config = new Configuration();
            config.Configure();

            // Auto load entity mapping class
            ModelMapper mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetAssembly(typeof(Employee)).GetExportedTypes());

            HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            config.AddDeserializedMapping(mapping, "NHibernate.Mapping");

            SchemaMetadataUpdater.QuoteTableAndColumns(config);

            // Drop & Recreate database schema
            new SchemaExport(config).Drop(false, true);
            new SchemaExport(config).Create(false, true);

            // Register services
            services.AddSingleton<ISessionFactory>(provider => config.BuildSessionFactory());
            services.AddTransient<ISession>(provider => services.BuildServiceProvider().GetService<ISessionFactory>().OpenSession());
        }
        public static IServiceCollection AddDataManagementForEntityFrameworkSqlite(this IServiceCollection services, IConfiguration configuration) {
            services.AddEntityFramework()
                .AddSqlite()
                .AddDbContext<ProductNameContext>(options => options.UseSqlite(configuration["Data:SqliteConnection:ConnectionString"]));
            services.AddTransient<IHandleProductNameData, EFProductNameDataAccessor>();

            return services;
        }
 public static IServiceCollection AddSqlConnectionBuilder(this IServiceCollection collection,
     string configuration)
 {
     var connection = new NpgsqlConnection(configuration);
     connection.OpenAsync();
     collection.AddTransient(provider => connection);
     return collection;
 }
    public static IServiceCollection AddRaygun(this IServiceCollection services, IConfigurationRoot configuration)
    {
      services.Configure<RaygunSettings>(configuration.GetSection("RaygunSettings"));

      services.AddTransient<IRaygunAspNetCoreClientProvider>(_ => new DefaultRaygunAspNetCoreClientProvider());
      services.AddSingleton<RaygunMiddlewareSettings>();

      return services;
    }
 public static IServiceCollection AddProceesProviderServices(this IServiceCollection serviceCollection)
 {
     return serviceCollection
         .AddTransient<IProcessFactory, ProcessFactory>()
         .AddTransient<IOutputProcessExecutor, OutputProcessExecutor>()
         .AddTransient<IFinishingProcessExecutor, FinishingProcessExecutor>()
         .AddTransient<ILongRunningExecutor, LongRunningExecutor>()
         .AddSingleton<IProcessExecutorProvider, ProcessExecutorProvider>();
 }