当前位置: 首页>>代码示例>>C#>>正文


C# IServiceContainer.Set方法代码示例

本文整理汇总了C#中IServiceContainer.Set方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceContainer.Set方法的具体用法?C# IServiceContainer.Set怎么用?C# IServiceContainer.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServiceContainer的用法示例。


在下文中一共展示了IServiceContainer.Set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        public void Configure(IServiceContainer serviceContainer)
        {
            serviceContainer.Set(x => (ISparkSettings)ConfigurationManager.GetSection("spark") ?? new SparkSettings());

            serviceContainer.Set<ISparkViewEngine>(x => new global::Spark.SparkViewEngine(x.Resolve<ISparkSettings>())
            {
                DefaultPageBaseType = typeof(UWebSparkView).FullName,
                ViewFolder = new UWebViewFolder(x.Resolve<ITemplateFinderCollection>().IncludeExtension(".spark").Find())
            });

            serviceContainer.Add<IViewEngine, SparkViewEngine>();
            serviceContainer.Set<IDescriptorBuilder, DefaultDescriptorBuilder>(ServiceLifeCycle.Transient);
            serviceContainer.Add<IFindModelFromView, FindModelFromSparkView>();
        }
开发者ID:UStack,项目名称:UWeb,代码行数:14,代码来源:SparkViewEngineConfiguration.cs

示例2: Configure

 public void Configure(IServiceContainer serviceContainer)
 {
     serviceContainer.Set(typeof(IAuthenticationService), typeof(AuthenticationService), ServiceLifeCycle.Transient);
     serviceContainer.Set(basicAuthenticationCookieConfiguration);
 }
开发者ID:UStack,项目名称:UWeb,代码行数:5,代码来源:BasicAuthenticationConfiguration.cs

示例3: ConfigureContainer

        protected virtual void ConfigureContainer(IServiceContainer serviceContainer)
        {
            if (serviceContainer == null) throw new ConfigurationException("You need to register a service container");

            serviceContainer.Set(GetRootPathProvider);

            serviceContainer.Set<IResolveDependencies>(serviceContainer);
            serviceContainer.Set(serviceContainer);
            serviceContainer.Set<IRouteCollection, RouteCollection>(ServiceLifeCycle.Singleton);
            serviceContainer.Set<IFindModelFromViewCollection, FindModelFromViewCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<ITemplateFinderCollection, TemplateFinderCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IFileScanner, FileScanner>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IUWebEngine, UWebEngine>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IOutputWriter, OutputWriter>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IRoutePatternMatcher, DefaultRoutePatternMatcher>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IRequestBinder, DefaultRequestBinder>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IRouteBuilderFactory, DefaultRouteBuilderFactory>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IEncryptionService, DefaultEncryptionService>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IJsonParser, DefaultJsonParser>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IModelBinderCollection, ModelBinderCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IBindingSourceCollection, BindingSourceCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IValueConverterCollection, ValueConverterCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IPropertyBinderCollection, PropertyBinderCollection>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IViewEngineCollection, ViewEngineCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IRenderEndpointResultCollection, RenderEndpointResultCollection>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IFileSystem, FileSystem>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IFilterViewsCollection, FilterViewsCollection>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IPostPipelineCollection, PostPipelineCollection>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IPrePipelineCollection, PrePipelineCollection>(ServiceLifeCycle.Transient);

            serviceContainer.Set<ISendSystemMessage, DefaultSendSystemMessage>(ServiceLifeCycle.Transient);
            serviceContainer.Set<ILoggerCollection, LoggerCollection>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IHttpUtility, HttpUtility>(ServiceLifeCycle.Transient);
            serviceContainer.Set<IHttpEncoder, HttpEncoder>(ServiceLifeCycle.Transient);

            serviceContainer.Add<IHandleSystemMessage<LogMessage>, HandleLogMessage>();

            serviceContainer.Set<IFindNextRequestChainPart, FindNextRequestChainPart>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IGetInputName, DefaultGetInputName>(ServiceLifeCycle.Transient);

            serviceContainer.Set<ICache, DefaultCache>(ServiceLifeCycle.Transient);
            serviceContainer.Set<ISessionProvider, DefaultSessionProvider>(ServiceLifeCycle.Transient);
            serviceContainer.Set<ISession, DefaultSession>(ServiceLifeCycle.Transient);
            serviceContainer.Set<ISessionIdProvider, DefaultSessionIdProvider>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IAntiXssTokenProvider, DefaultAntiXssTokenProvider>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IAuthenticationRuleCollection, AuthenticationRuleCollection>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IUrlBuilder, DefaultUrlBuilder>(ServiceLifeCycle.Transient);

            serviceContainer.Set<IAuthenticationService, NulloAuthenticationService>(ServiceLifeCycle.Transient);
            serviceContainer.Set(x =>
            {
                var authenticationService = x.Resolve<IAuthenticationService>();
                return authenticationService == null ? null : authenticationService.GetCurrent();
            });

            serviceContainer.Set(x => x.ResolveAll<IBindingSource>());
            serviceContainer.Set(x => x.ResolveAll<IFindViewsForEndpoint>());
            serviceContainer.Set(x => x.ResolveAll<IFindModelFromView>());
            serviceContainer.Set(x => x.ResolveAll<IModelBinder>());
            serviceContainer.Set(x => x.ResolveAll<IPostPipeline>());
            serviceContainer.Set(x => x.ResolveAll<IPrePipeline>());
            serviceContainer.Set(x => x.ResolveAll<IHandleEndpointResult>());
            serviceContainer.Set(x => x.ResolveAll<ITemplateFinder>());
            serviceContainer.Set(x => x.ResolveAll<IValueConverter>());
            serviceContainer.Set(x => x.ResolveAll<IViewEngine>());
            serviceContainer.Set(x => x.ResolveAll<ILogger>());
            serviceContainer.Set(x => x.ResolveAll<IPropertyBinder>());
            serviceContainer.Set<IEnumerable<IEndpoint>>(x => x.Resolve<IApplicationEndpoints>());
        }
开发者ID:UStack,项目名称:UWeb,代码行数:80,代码来源:UWebBootstrapper.cs

示例4: Configure

 public void Configure(IServiceContainer container)
 {
     container.Set<IAuthenticationService, FakeAuthenticationService>(ServiceLifeCycle.Transient);
 }
开发者ID:UStack,项目名称:UWeb,代码行数:4,代码来源:FakeAuthenticationConfiguration.cs


注:本文中的IServiceContainer.Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。