本文整理汇总了C#中IServiceContainer.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceContainer.Add方法的具体用法?C# IServiceContainer.Add怎么用?C# IServiceContainer.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceContainer
的用法示例。
在下文中一共展示了IServiceContainer.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>();
}
示例2: 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>());
}