private static void SetupExternal(IServiceConfigurationProvider container) { container.AddTransient <IBlobFilenameRepository, BlobFilenameRepository>(); container.AddTransient <IImageRepository, ImageRepository>(); container.AddTransient <IBlobRepository, BlobRepository>(); container.AddTransient <ICart>(x => x.GetInstance <ICartFactory>().LoadOrCreateCart()); container.AddSingleton <ICookieHelper, CookieHelper>(); container.AddSingleton <ICookieRepository>(x => new CookieRepository(false, x.GetInstance <ICookieHelper>())); container.AddSingleton <IVocabulary>(x => CreateVocabulary(x.GetInstance <IBlobRepository>())); container.AddSingleton <ITernaryTreeFactory, TernaryTreeFactory>(); container.AddSingleton <ITernarySearch>(x => x.GetInstance <ITernaryTreeFactory>().GenerateTree()); container.AddSingleton <ITokinizer>(new Tokinizer(new HashSet <string>() { "-", "!", "?", ".", "\"", "(", ")", ":", ";", "," })); container.AddSingleton <IDocumentStorage, DocumentStore>(); container.AddSingleton <SearchFactory, SearchFactory>(); container.AddSingleton <ISearchEngine>(x => x.GetInstance <SearchFactory>().CreateSearch()); container.AddSingleton <IBiGram>(x => x.GetInstance <SearchFactory>().CreateBiGram()); container.AddSingleton <ITriGram>(x => x.GetInstance <SearchFactory>().CreateTriGram()); container.AddSingleton <ISentencezer>(new Sentencezer(new Tokinizer(new HashSet <string>() { "-", "\"", "(", ")", ":", ";", "," }))); container.AddSingleton <IConnectionSettingsValues>(new ConnectionSettings(new Uri("http://localhost:9200")).DefaultIndex("movie")); container.AddSingleton <ElasticClient>(s => new ElasticClient(s.GetInstance <IConnectionSettingsValues>())); container.AddSingleton <IMovieSearch, MovieSearch>(); }
private static void SetupMediaR(IServiceConfigurationProvider container) { try { var test = typeof(ProductHandle); var types = AppDomain.CurrentDomain.GetAssemblies() .Where(x => x.FullName.StartsWith("MovieShop")) .SelectMany(s => s.GetTypes()); foreach (var type in types) { foreach (Type intType in type.GetInterfaces()) { if (intType.IsGenericType && intType.GetGenericTypeDefinition() == typeof(IRequestHandler <,>)) { container.AddTransient(intType, type); } } } container.AddSingleton <ServiceFactory>(ctx => ctx.GetInstance); container.AddTransient <IMediator, Mediator>(); } catch (Exception ex) { throw; } }
public TargetInstanceFactory(IOptions <InjectionOptions> options, ILogger <TargetInstanceFactory <TConfiguration> > logger, IServiceConfigurationProvider <TConfigurationKey, TConfiguration> configurationProvider, IHttpContextAccessor httpContextAccessor) { _Options = options.Value; _Logger = logger; _ConfigurationProvider = configurationProvider; _HttpContextAccessor = httpContextAccessor; }
/// <summary> /// Add classes with [Registration] attributes to Episerver Service Locator. /// </summary> /// <param name="services"></param> /// <param name="assembliesToScan">DiscoveredAssemblies to scan for types with RegistrationAttribute, /// if null DiscoveredAssemblies with DiscoverableAssemblyAttribute are used to filter.</param> /// <param name="dependentRegistrationFactory">Optional custom IDependentRegistrationFacory</param> /// <param name="registrationSorter">Optional custom registration sorter.</param> /// <param name="addServiceAccessor">Optional function to determine if a service accessor is needed for Inject<T> usages</param> /// <param name="registrationFilter">Optional action to modify regististrations, add/remove or changelifestyle.</param> public static void AddDotNetStarterRegistrations ( this IServiceConfigurationProvider services, IEnumerable <Assembly> assembliesToScan = null, IDependentRegistrationFactory dependentRegistrationFactory = null, IRegistrationSorter registrationSorter = null, Func <DependentRegistration, bool> addServiceAccessor = null, Action <ICollection <DependentRegistration> > registrationFilter = null ) { var assemblies = assembliesToScan ?? AssemblyLoader() .Where(a => a.GetCustomAttribute <DiscoverableAssemblyAttribute>() != null); var registrations = (dependentRegistrationFactory ?? new DependentRegistrationFactory()). CreateDependentRegistrations(assemblies); registrationFilter?.Invoke(registrations); (registrationSorter ?? new RegistrationSorter()).Sort(registrations); foreach (var t in registrations) { var service = services.Add ( t.Registration.ServiceType, t.Implementation, (t.CustomLifeCycle ?? t.Registration.Lifecycle).ConvertToServiceLifetime() ); if (addServiceAccessor?.Invoke(t) == true) { service.AddServiceAccessor(); } } }
/// <summary> /// Adds ServiceDescriptor to Episerver services /// </summary> /// <param name="serviceConfiguration"></param> /// <param name="serviceCollection"></param> /// <returns></returns> public static IServiceConfigurationProvider AddServiceCollection(this IServiceConfigurationProvider serviceConfiguration, IServiceCollection serviceCollection) { foreach (var service in serviceCollection) { if (service.ImplementationInstance != null) { serviceConfiguration.Add(service.ServiceType, service.ImplementationInstance); } else if (service.ImplementationFactory != null) { serviceConfiguration.Add ( service.ServiceType, (locator) => locator.GetService(service.ServiceType), ConvertLifeTime(service.Lifetime) ); } else if (service.ImplementationType != null) { serviceConfiguration.Add ( service.ServiceType, service.ImplementationType, ConvertLifeTime(service.Lifetime) ); } } return(serviceConfiguration); }
public static void UserDefaultService(this IServiceConfigurationProvider serviceConfigurationProvider) { serviceConfigurationProvider.AddHttpContextOrThreadScoped <ISearchService, EpiserverFindService>(); serviceConfigurationProvider.AddSingleton <IQueryComposerResolver, DefaultQueryComposerResolver>(); serviceConfigurationProvider.AddHttpContextOrThreadScoped <IQueryComposer, ListingComposer>(); serviceConfigurationProvider.AddHttpContextOrThreadScoped <IQueryComposer, CustomizedListingComposer>(); }
public static void Setup(IServiceConfigurationProvider container) { SetupDefaultConvention(container); SetupFeatureModules(container); SetupExternal(container); SetupMediaR(container); SetupSettings(container); }
/// <summary>Configure the IoC container before initialization.</summary> /// <param name="context">The context on which the container can be accessed.</param> public void ConfigureContainer(ServiceConfigurationContext context) { IServiceConfigurationProvider services = context.Services; services.AddSingleton <IPredictionEngineService, PredictionEngineService>(); services.AddSingleton <CatalogContentEventListener, CatalogContentEventListener>(); }
public void ConfigureContainer(ServiceConfigurationContext context) { _services = context.Services; context.ConfigureFoundationCms(); _services.Configure <ContentApiConfiguration>(c => { c.EnablePreviewFeatures = true; c.Default().SetMinimumRoles(string.Empty).SetRequiredRole(string.Empty); }); _services.Configure <ContentApiSearchConfiguration>(config => { config.Default() .SetMaximumSearchResults(200) .SetSearchCacheDuration(TimeSpan.FromMinutes(60)); }); _services.AddSingleton <IDisplayModeFallbackProvider, FoundationDisplayModeProvider>(); _services.AddTransient <IQuickNavigatorItemProvider, FoundationQuickNavigatorItemProvider>(); _services.AddTransient <IViewTemplateModelRegistrator, ViewTemplateModelRegistrator>(); _services.AddSingleton <IHeaderViewModelFactory, HeaderViewModelFactory>(); _services.AddSingleton <BlogTagFactory>(); _services.AddSingleton <ISearchService, SearchService>(); _services.AddSingleton <ISearchViewModelFactory, SearchViewModelFactory>(); _services.AddSingleton <IModelBinderProvider, FindModelBinderProvider>(); _services.AddTransient <IContentQuery, LandingPagesSlice>(); _services.AddTransient <IContentSlice, LandingPagesSlice>(); _services.AddTransient <IContentQuery, StandardPagesSlice>(); _services.AddTransient <IContentSlice, StandardPagesSlice>(); _services.AddTransient <IContentQuery, BlogsSlice>(); _services.AddTransient <IContentSlice, BlogsSlice>(); _services.AddTransient <IContentQuery, BlocksSlice>(); _services.AddTransient <IContentSlice, BlocksSlice>(); _services.AddTransient <IContentQuery, MediaSlice>(); _services.AddTransient <IContentSlice, MediaSlice>(); _services.AddTransient <IContentQuery, ImagesSlice>(); _services.AddTransient <IContentSlice, ImagesSlice>(); _services.AddTransient <IContentQuery, EverythingSlice>(); _services.AddTransient <IContentSlice, EverythingSlice>(); _services.AddTransient <IContentQuery, MyContentSlice>(); _services.AddTransient <IContentSlice, MyContentSlice>(); _services.AddTransient <IContentQuery, MyPagesSlice>(); _services.AddTransient <IContentSlice, MyPagesSlice>(); _services.AddTransient <IContentQuery, UnusedMediaSlice>(); _services.AddTransient <IContentSlice, UnusedMediaSlice>(); _services.AddTransient <IContentQuery, UnusedBlocksSlice>(); _services.AddTransient <IContentSlice, UnusedBlocksSlice>(); _services.AddSingleton <ISchemaDataMapper <BlogItemPage>, BlogItemPageSchemaMapper>(); _services.AddSingleton <ISchemaDataMapper <HomePage>, HomePageSchemaMapper>(); _services.AddSingleton <ISchemaDataMapper <LocationItemPage>, LocationItemPageSchemaDataMapper>(); // Foundation.Features.Shared _services.AddSingleton <IMailService, MailService>(); _services.AddSingleton <IHtmlDownloader, HtmlDownloader>(); }
public static void Add(this IServiceConfigurationProvider container, Dictionary <Type, Type> typeDictionary) { if (typeDictionary == null) { return; } foreach (var entry in typeDictionary) { container.AddScoped(entry.Key, entry.Value); } }
/// <summary>Configure the IoC container before initialization.</summary> /// <param name="context">The context on which the container can be accessed.</param> public void ConfigureContainer(ServiceConfigurationContext context) { if (context == null) { return; } IServiceConfigurationProvider services = context.Services; services.AddSingleton <ISettingsService, SettingsService>(); }
public static void RegisterVueStorefrontBridgeDefaultService(this IServiceConfigurationProvider services, VsfApiBridgeConfiguration bridgeConfiguration) { services.AddSingleton(bridgeConfiguration); services.AddTransient <IUserEndpoint, UserEndpoint <VsfUser> >(); services.AddTransient <ICartEndpoint, CartEndpoint>(); services.AddTransient <IStockEndpoint, StockEndpoint>(); services.AddTransient <IOrderEndpoint, OrderEndpoint>(); services.AddScoped <QuicksilverDbContext>(); services.AddScoped <IRefreshTokenRepository, DatabaseRefreshTokenRepository>(); services.AddScoped <IUserTokenProvider, JwtUserTokenProvider>(); services.AddTransient <IUserClaimsProvider <VsfUser>, UserClaimsProvider <VsfUser> >(); }
void IConfigurableModule.ConfigureContainer(ServiceConfigurationContext context) { _services = context.Services; _services.AddTransient(_ => HttpContext.Current.GetOwinContext()); _services.AddTransient(locator => locator.GetInstance <IOwinContext>().GetUserManager <ApplicationUserManager <SiteUser> >()).AddServiceAccessor(); _services.AddTransient(locator => locator.GetInstance <IOwinContext>().Authentication).AddServiceAccessor(); _services.AddTransient(locator => locator.GetInstance <IOwinContext>().Get <ApplicationSignInManager <SiteUser> >()).AddServiceAccessor(); _services.AddTransient <IsInEditModeAccessor>(locator => () => PageEditing.PageIsInEditMode); _services.AddSingleton <ServiceAccessor <IContentRouteHelper> >(locator => locator.GetInstance <IContentRouteHelper>); _services.AddTransient <IModelBinderProvider, ModelBinderProvider>(); _services.AddSingleton <IUserService, UserService>(); _services.AddSingleton <CookieService>(); }
public static void RegisterVueStorefrontExporterDefaultService <TProduct>(this IServiceConfigurationProvider services, VsfExporterConfiguration vsfExporterConfiguration) where TProduct : VsfBaseProduct { services.AddSingleton(vsfExporterConfiguration); services.AddTransient <IAttributeMapper, AttributeMapper>(); services.AddTransient <IMapper <VariationContent, VsfSimpleProduct>, SimpleProductMapper>(); services.AddTransient <IContentExtractor, ContentExtractor>(); services.AddSingleton <IVsfPriceService, VsfPriceService>(); services.AddTransient <IExtractedContentHandler, ExtractedContentHandler <TProduct> >(); services.AddTransient <IIndexingService, IndexingService <TProduct> >(); services.AddTransient <IContentLoaderWrapper, CachedContentLoaderWrapper>(sc => new CachedContentLoaderWrapper(new ContentLoaderWrapper(sc.GetInstance <IContentLoader>()))); }
void IConfigurableModule.ConfigureContainer(ServiceConfigurationContext context) { _services = context.Services; _services.AddTransient(_ => HttpContext.Current.GetOwinContext()); _services.AddTransient(locator => locator.GetInstance <IOwinContext>().GetUserManager <ApplicationUserManager <SiteUser> >()).AddServiceAccessor(); _services.AddTransient(locator => locator.GetInstance <IOwinContext>().Authentication).AddServiceAccessor(); _services.AddTransient(locator => locator.GetInstance <IOwinContext>().Get <ApplicationSignInManager <SiteUser> >()).AddServiceAccessor(); _services.AddSingleton <IDisplayModeFallbackProvider, FoundationDisplayModeProvider>(); _services.AddTransient <IsInEditModeAccessor>(locator => () => PageEditing.PageIsInEditMode); _services.AddSingleton <ServiceAccessor <IContentRouteHelper> >(locator => locator.GetInstance <IContentRouteHelper>); _services.AddTransient <IModelBinderProvider, ModelBinderProvider>(); _services.AddSingleton <CookieService>(); _services.AddSingleton <BlogTagFactory>(); _services.AddTransient <IQuickNavigatorItemProvider, FoundationQuickNavigatorItemProvider>(); _services.AddTransient <IViewTemplateModelRegistrator, ViewTemplateModelRegistrator>(); }
private static void SetupFeatureModules(IServiceConfigurationProvider container) { try { var types = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.StartsWith("MovieShop")).SelectMany(s => s.GetTypes()).Where(p => typeof(IDependencyInjectionConfig).IsAssignableFrom(p) && !p.IsInterface); foreach (var type in types) { var methodInfo = type.GetMethod(nameof(IDependencyInjectionConfig.Setup)); var classInstance = Activator.CreateInstance(type, null); methodInfo.Invoke(classInstance, new object[] { container }); } } catch (Exception ex) { throw; } }
private ServiceConfigurationStore() { var providerTypeName = ConfigurationManager.AppSettings[Constants.ServiceConfigurationProviderTypeAppSettingName]; if (!string.IsNullOrEmpty(providerTypeName)) { var providerType = Type.GetType(providerTypeName); if (providerType != null) { _provider = (IServiceConfigurationProvider)Activator.CreateInstance(providerType); } } if (_provider == null) { _provider = new DefaultServiceConfigurationProvider(); } _cachedBindingTypes = _provider.GetBindingTypes(); _cachedCustomBehaviorTypes = _provider.GetCustomBehaviorTypes(); _cachedServiceHostTypes = _provider.GetServiceHostTypes(); }
public IActionResult About([FromServices] IServiceProvider provider, [FromServices] IServiceConfigurationProvider <string, MemoryServiceConfigurationProvider.MemoryConfig> settings, string @in, string @out, bool asEnum = false) { (settings as MemoryServiceConfigurationProvider).SetInAndOut(@in, @out); try { if (asEnum) { var dummy = provider.GetService(typeof(IEnumerable <IDummy>)) as IEnumerable <IDummy>; ViewData["Message"] = string.Join(" / ", dummy.Select(t => t.GetDummy())); } else { var dummy = provider.GetService(typeof(IDummy)) as IDummy; ViewData["Message"] = dummy.GetDummy(); } } catch (Exception e) { ViewData["Message"] = e.Message; } return(View()); }
/// <summary>Configure the IoC container before initialization.</summary> /// <param name="context">The context on which the container can be accessed.</param> public void ConfigureContainer(ServiceConfigurationContext context) { IServiceConfigurationProvider services = context.Services; services.AddSingleton <IRecommendationRepository, RecommendationRepository>(); }
public void Setup(IServiceConfigurationProvider container) { container.AddSingleton <IViewModelFactory, ViewModelFactory>(); }
public void Setup(IServiceConfigurationProvider container) { container.AddSingleton <ICurrentMarket, CurrentMarket>(); container.AddSingleton <ICurrentCurrency, CurrentCurrency>(); }
public void RegisterDependencies(IServiceConfigurationProvider services) { services.AddScoped <StartPageViewModelFactory>(); services.AddScoped <ArticlePageViewModeFactory>(); }
public void ConfigureContainer(ServiceConfigurationContext context) { _services = context.Services; context.ConfigureFoundationCms(); _services.Configure <ContentApiConfiguration>(c => { c.EnablePreviewFeatures = true; c.Default().SetMinimumRoles(string.Empty).SetRequiredRole(string.Empty); }); _services.Configure <ContentApiSearchConfiguration>(config => { config.Default() .SetMaximumSearchResults(200) .SetSearchCacheDuration(TimeSpan.FromMinutes(60)); }); _services.AddSingleton <IDisplayModeFallbackProvider, FoundationDisplayModeProvider>(); _services.AddTransient <IQuickNavigatorItemProvider, FoundationQuickNavigatorItemProvider>(); _services.AddTransient <IViewTemplateModelRegistrator, ViewTemplateModelRegistrator>(); _services.AddSingleton <DefaultPlacedPriceProcessor, FoundationPlacedPriceProcessor>(); _services.AddSingleton <ISearchViewModelFactory, SearchViewModelFactory>(); _services.AddSingleton <IPaymentService, PaymentService>(); _services.AddTransient <CheckoutViewModelFactory>(); _services.AddSingleton <MultiShipmentViewModelFactory>(); _services.AddSingleton <OrderSummaryViewModelFactory>(); _services.AddTransient <PaymentMethodViewModelFactory>(); _services.AddSingleton <IBookmarksService, BookmarksService>(); _services.AddSingleton <IPricingService, PricingService>(); _services.AddSingleton <IB2BNavigationService, B2BNavigationService>(); _services.AddSingleton <IBudgetService, BudgetService>(); _services.AddSingleton <ICreditCardService, CreditCardService>(); _services.AddSingleton <IGiftCardService, GiftCardService>(); _services.AddSingleton <IOrganizationService, OrganizationService>(); _services.AddSingleton <IQuickOrderService, QuickOrderService>(); _services.AddSingleton <IProductService, ProductService>(); _services.AddSingleton <IPromotionService, PromotionService>(); _services.AddSingleton <IStoreService, StoreService>(); _services.AddSingleton <CatalogEntryViewModelFactory>(); _services.AddSingleton <IHeaderViewModelFactory, HeaderViewModelFactory>(); _services.AddSingleton <IAddressBookService, AddressBookService>(); _services.AddSingleton <CartItemViewModelFactory>(); _services.AddSingleton <ICartService, CartService>(); _services.AddSingleton <CartViewModelFactory>(); _services.AddSingleton <IOrdersService, OrdersService>(); _services.AddSingleton <ShipmentViewModelFactory>(); _services.AddSingleton <IShippingService, ShippingService>(); _services.AddSingleton <ICampaignService, CampaignService>(); _services.AddSingleton <IHtmlDownloader, HtmlDownloader>(); _services.AddTransient <IMailService, MailService>(); _services.AddSingleton <BlogTagFactory>(); _services.AddTransient <IPaymentMethod, BudgetPaymentOption>(); _services.AddTransient <IPaymentMethod, CashOnDeliveryPaymentOption>(); _services.AddTransient <IPaymentMethod, GenericCreditCardPaymentOption>(); _services.AddTransient <IPaymentMethod, GiftCardPaymentOption>(); _services.AddSingleton <ISearchService, SearchService>(); _services.AddSingleton <CatalogContentClientConventions, FoundationFindConventions>(); _services.AddSingleton <CatalogContentEventListener, FoundationCatalogContentEventListener>(); _services.AddSingleton <IModelBinderProvider, FilterOptionModelBinderProvider>(); _services.AddSingleton <IModelBinderProvider, PaymentModelBinderProvider>(); _services.AddTransient <IContentQuery, LandingPagesSlice>(); _services.AddTransient <IContentSlice, LandingPagesSlice>(); _services.AddTransient <IContentQuery, StandardPagesSlice>(); _services.AddTransient <IContentSlice, StandardPagesSlice>(); _services.AddTransient <IContentQuery, BlogsSlice>(); _services.AddTransient <IContentSlice, BlogsSlice>(); _services.AddTransient <IContentQuery, BlocksSlice>(); _services.AddTransient <IContentSlice, BlocksSlice>(); _services.AddTransient <IContentQuery, MediaSlice>(); _services.AddTransient <IContentSlice, MediaSlice>(); _services.AddTransient <IContentQuery, ImagesSlice>(); _services.AddTransient <IContentSlice, ImagesSlice>(); _services.AddTransient <IContentQuery, EverythingSlice>(); _services.AddTransient <IContentSlice, EverythingSlice>(); _services.AddTransient <IContentQuery, MyContentSlice>(); _services.AddTransient <IContentSlice, MyContentSlice>(); _services.AddTransient <IContentQuery, MyPagesSlice>(); _services.AddTransient <IContentSlice, MyPagesSlice>(); _services.AddTransient <IContentQuery, UnusedMediaSlice>(); _services.AddTransient <IContentSlice, UnusedMediaSlice>(); _services.AddTransient <IContentQuery, UnusedBlocksSlice>(); _services.AddTransient <IContentSlice, UnusedBlocksSlice>(); _services.AddTransient <IContentQuery, ProductsSlice>(); _services.AddTransient <IContentSlice, ProductsSlice>(); _services.AddTransient <IContentQuery, PackagesSlice>(); _services.AddTransient <IContentSlice, PackagesSlice>(); _services.AddTransient <IContentQuery, BundlesSlice>(); _services.AddTransient <IContentSlice, BundlesSlice>(); _services.AddTransient <IContentQuery, VariantsSlice>(); _services.AddTransient <IContentSlice, VariantsSlice>(); _services.AddTransient <IContentQuery, OrderPromotionsSlice>(); _services.AddTransient <IContentSlice, OrderPromotionsSlice>(); _services.AddTransient <IContentQuery, ShippingPromotionsSlice>(); _services.AddTransient <IContentSlice, ShippingPromotionsSlice>(); _services.AddTransient <IContentQuery, EntryPromotionsSlice>(); _services.AddTransient <IContentSlice, EntryPromotionsSlice>(); _services.AddSingleton <ISchemaDataMapper <BlogItemPage>, BlogItemPageSchemaMapper>(); _services.AddSingleton <ISchemaDataMapper <HomePage>, HomePageSchemaMapper>(); _services.AddSingleton <ISchemaDataMapper <GenericProduct>, GenericProductSchemaDataMapper>(); _services.AddSingleton <ISchemaDataMapper <LocationItemPage>, LocationItemPageSchemaDataMapper>(); }
private static void ConfigureContainer(IServiceConfigurationProvider services) { services.AddSingleton <ICategoryContentLoader, DefaultCategoryContentLoader>(); services.AddSingleton <IContentInCategoryLocator, DefaultContentInCategoryLocator>(); services.AddScoped <ICategoryRouteHelper, DefaultCategoryRouteHelper>(); }
public static void SetupDefaultConvention(IServiceConfigurationProvider container) { container.Add(AssemblyScanner.ForAssamby <DependencyResolverInitialization>().GetInterfaceWithDefaultConventions()); }
private static void SetupSettings(IServiceConfigurationProvider container) { container.AddTransient <IMenuSettings>(x => x.GetInstance <ISettingsService>().GetSetting <IMenuSettings>()); }
public void Setup(IServiceConfigurationProvider container) { container.AddSingleton <ISettingService, SettingService>(); }
private static void AddHybridServices(IServiceConfigurationProvider configurationProvider) { configurationProvider.AddHttpContextOrThreadScoped <IUrlService, UrlService>(); }