/// <summary> /// 注册组件 /// </summary> public static void RegisterComponents() { AssemblyConfigLocalMember assemblyConfigLocalMember = new AssemblyConfigLocalMember(); assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigXml(); AssemblyConfigInfo assemblyConfig = assemblyConfigLocalMember.Reader(); //实例化一个autofac的创建容器 var builder = new ContainerBuilder(); IContainer container = builder.UnifiedRegisterAssemblysForWebApi2(GlobalConfiguration.Configuration, new WebBuilderParam() { AssemblyControllers = assemblyConfig.Entrances, AssemblyServices = assemblyConfig.Services, RegisteringServiceAction = () => { builder.RegisterType <IdentityHttpFormAuth>().As <IIdentityAuthVali>().AsSelf().PropertiesAutowired(); builder.RegisterType <IdentityHttpFormAuth>().As <IIdentityExit>().AsSelf().PropertiesAutowired(); builder.RegisterType <IdentityHttpFormAuth>().AsSelf().PropertiesAutowired(); } }); AttachmentService attachmentService = AutofacTool.Resolve <AttachmentService>(); AttachmentOwnerLocalMember attachmentOwnerLocalMember = AutofacTool.Resolve <AttachmentOwnerLocalMember>(); attachmentOwnerLocalMember.ProtoAttachmentOwnerReader = AutofacTool.Resolve <AttachmentOwnerXml>(); attachmentService.AttachmentOwnerReader = attachmentOwnerLocalMember; }
/// <summary> /// 注册组件 /// </summary> /// <param name="builder">内容生成</param> public static void RegisterComponents(ContainerBuilder builder) { AssemblyConfigLocalMember assemblyConfigLocalMember = new AssemblyConfigLocalMember(); assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigJson(); AssemblyConfigInfo assemblyConfig = assemblyConfigLocalMember.Reader(); builder.UnifiedRegisterAssemblysV3_0(new BuilderParam() { AssemblyServices = assemblyConfig.Services, IsLoadAutoMapperConfig = assemblyConfig.IsLoadAutoMapperConfig, RegisteringServiceAction = () => { builder.RegisterType <WorkflowConfigCache>().As <IWorkflowConfigReader>().AsSelf().PropertiesAutowired(); builder.RegisterType <WorkflowInitSequenceService>().As <IWorkflowFormService>().AsSelf().PropertiesAutowired(); builder.RegisterType <AutofacInstance>().As <IInstance>().AsSelf().PropertiesAutowired().SingleInstance(); builder.RegisterType <IntegrationNLog>().As <ILogable>().AsSelf().PropertiesAutowired().SingleInstance(); } }); builder.RegisterBuildCallback(container => { PlatformTool.AppConfig = container.Resolve <IAppConfiguration>(); AttachmentService attachmentService = container.Resolve <AttachmentService>(); AttachmentOwnerLocalMember attachmentOwnerLocalMember = container.Resolve <AttachmentOwnerLocalMember>(); attachmentOwnerLocalMember.ProtoAttachmentOwnerReader = container.Resolve <AttachmentOwnerJson>(); attachmentService.AttachmentOwnerReader = attachmentOwnerLocalMember; }); }
/// <summary> /// 注册组件 /// </summary> /// <param name="services">服务</param> /// <returns>服务提供者</returns> public static IServiceProvider RegisterComponents(IServiceCollection services) { AssemblyConfigLocalMember assemblyConfigLocalMember = new AssemblyConfigLocalMember(); assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigJson(); AssemblyConfigInfo assemblyConfig = assemblyConfigLocalMember.Reader(); //实例化一个autofac的创建容器 var builder = new ContainerBuilder(); IServiceProvider serviceProvider; builder.UnifiedRegisterAssemblys(services, new BuilderParam() { AssemblyServices = assemblyConfig.Services, RegisteringServiceAction = () => { builder.RegisterType <HttpContextAccessor>().As <IHttpContextAccessor>().AsSelf().PropertiesAutowired(); builder.RegisterType <IdentityCookieAuth>().As <IIdentityAuthVali>().AsSelf().PropertiesAutowired(); builder.RegisterType <IdentityCookieAuth>().As <IIdentityExit>().AsSelf().PropertiesAutowired(); builder.RegisterType <WorkflowConfigCache>().As <IWorkflowConfigReader>().AsSelf().PropertiesAutowired(); builder.RegisterType <WorkflowInitSequenceService>().As <IWorkflowFormService>().AsSelf().PropertiesAutowired(); //builder.RegisterInstance() builder.RegisterType <LanguageLibraryCache>().As <ILanguageLibrary>().AsSelf().PropertiesAutowired(); builder.RegisterType <LanguageLibraryConfigJson>().As <IReaderAll <LanguageInfo> >().AsSelf().PropertiesAutowired(); } }, out serviceProvider); AttachmentService attachmentService = AutofacTool.Resolve <AttachmentService>(); AttachmentOwnerLocalMember attachmentOwnerLocalMember = AutofacTool.Resolve <AttachmentOwnerLocalMember>(); attachmentOwnerLocalMember.ProtoAttachmentOwnerReader = AutofacTool.Resolve <AttachmentOwnerJson>(); attachmentService.AttachmentOwnerReader = attachmentOwnerLocalMember; var languageCache = AutofacTool.Resolve <LanguageLibraryCache>(); // var languageJson = AutofacTool.Resolve<LanguageLibraryJson>(); //languageJson.JsonFile = @"F:\MyWorks\net\Hzdtf.FoundationFramework\WebDemoCore\Hzdtf.WebDemo.Core\Config\LanguageLibrary\test.min.json"; /// languageCache.ProtoLanguageLibraryReader = languageJson; LanguageUtil.LanguageLibrary = languageCache; return(serviceProvider); }
/// <summary> /// 注册组件 /// </summary> /// <param name="builder">内容生成</param> public static void RegisterComponents(ContainerBuilder builder) { var assemblyConfigLocalMember = new AssemblyConfigLocalMember(); assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigJson(); var assemblyConfig = assemblyConfigLocalMember.Reader(); builder.UnifiedRegisterAssemblysForWeb(new BuilderParam() { AssemblyServices = assemblyConfig.Services, IsLoadAutoMapperConfig = assemblyConfig.IsLoadAutoMapperConfig, RegisteringServiceAction = () => { //builder.RegisterType<WorkflowConfigCache>().As<IWorkflowConfigReader>().AsSelf().PropertiesAutowired(); // builder.RegisterType<WorkflowInitSequenceService>().As<IWorkflowFormService>().AsSelf().PropertiesAutowired(); builder.RegisterType <AutofacInstance>().As <IInstance>().AsSelf().PropertiesAutowired().SingleInstance(); builder.RegisterType <IntegrationNLog>().As <ILogable>().AsSelf().PropertiesAutowired().SingleInstance(); builder.RegisterType <RoutePermissionCache>().As <IReader <RoutePermissionInfo[]> >().AsSelf().PropertiesAutowired().SingleInstance(); builder.RegisterType <CultureLibraryCache>().As <ICultureLibrary>().AsSelf().PropertiesAutowired().SingleInstance(); } }); builder.RegisterBuildCallback(container => { var attachmentService = container.Resolve <AttachmentService>(); AttachmentOwnerLocalMember attachmentOwnerLocalMember = container.Resolve <AttachmentOwnerLocalMember>(); attachmentOwnerLocalMember.ProtoAttachmentOwnerReader = container.Resolve <AttachmentOwnerJson>(); attachmentService.AttachmentOwnerReader = attachmentOwnerLocalMember; App.GetEventIdFunc = () => { var theOper = container.Resolve <ITheOperation>(); return(theOper != null ? theOper.EventId : null); }; }); }