Пример #1
0
        /// <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;
        }
Пример #2
0
        /// <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;
            });
        }
Пример #3
0
        /// <summary>
        /// 注册组件
        /// </summary>
        public static void RegisterComponents()
        {
            AssemblyConfigLocalMember assemblyConfigLocalMember = new AssemblyConfigLocalMember();

            assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigJson();
            AssemblyConfigInfo assemblyConfig = assemblyConfigLocalMember.Reader();

            var builder = new ContainerBuilder();

            builder.UnifiedRegisterAssemblys(new BuilderParam()
            {
                AssemblyServices         = assemblyConfig.Services,
                RegisteringServiceAction = () =>
                {
                    builder.RegisterType <AutofacInstance>().As <IInstance>().AsSelf().PropertiesAutowired().SingleInstance();
                    builder.RegisterType <MessagePackBytesSerialization>().As <IBytesSerialization>().AsSelf().PropertiesAutowired().SingleInstance();
                    builder.RegisterType <MessagePackConvertTypeValue>().As <IConvertTypeValue>().AsSelf().PropertiesAutowired().SingleInstance();
                }
            });
            PlatformTool.AppConfig = AutofacTool.Resolve <IAppConfiguration>();

            var implCache = AutofacTool.Resolve <InterfaceMapImplCache>();

            implCache.Set(new DictionaryJson($"{AppContext.BaseDirectory}/Config/interfaceAssemblyMapImplAssemblyConfig.json"));
        }
        /// <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);
        }
Пример #5
0
        static void Main()
        {
            AssemblyConfigLocalMember assemblyConfigLocalMember = new AssemblyConfigLocalMember();

            assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigXml();
            AssemblyConfigInfo assemblyConfig = assemblyConfigLocalMember.Reader();

            //实例化一个autofac的创建容器
            var        builder   = new ContainerBuilder();
            IContainer container = builder.UnifiedRegisterAssemblys(new BuilderParam()
            {
                AssemblyServices = assemblyConfig.Services
            });


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Main());
        }
Пример #6
0
        /// <summary>
        /// 注册组件
        /// </summary>
        public static void RegisterComponents()
        {
            AssemblyConfigLocalMember assemblyConfigLocalMember = new AssemblyConfigLocalMember();

            assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigJson();
            AssemblyConfigInfo assemblyConfig = assemblyConfigLocalMember.Reader();

            var builder = new ContainerBuilder();

            builder.UnifiedRegisterAssemblys(new BuilderParam()
            {
                AssemblyServices         = assemblyConfig.Services,
                RegisteringServiceAction = () =>
                {
                    builder.RegisterType <MessagePackBytesSerialization>().As <IBytesSerialization>().AsSelf().PropertiesAutowired().SingleInstance();
                    builder.RegisterType <MessagePackConvertTypeValue>().As <IConvertTypeValue>().AsSelf().PropertiesAutowired().SingleInstance();
                }
            });
            PlatformTool.AppConfig = AutofacTool.Resolve <IAppConfiguration>();
        }
Пример #7
0
        static void Main()
        {
            var assemblyConfigLocalMember = new AssemblyConfigLocalMember();

            assemblyConfigLocalMember.ProtoAssemblyConfigReader = new AssemblyConfigXml();
            var assemblyConfig = assemblyConfigLocalMember.Reader();

            //实例化一个autofac的创建容器
            var builder = new ContainerBuilder();

            builder.UnifiedRegisterAssemblys(new BuilderParam()
            {
                AssemblyServices = assemblyConfig.Services
            });

            App.CurrConfig = ConfigurationFactory.BuilderConfig();

            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Main());
        }
Пример #8
0
        /// <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);
                };
            });
        }