Ejemplo n.º 1
0
        public void Init()
        {
            //初始化配置文件
            Assembly      entryAssembly = Assembly.GetExecutingAssembly();
            Configuration configuration = ConfigurationExtension.GetConfigurationFromAssembly(entryAssembly);

            FrameworkSection.Initialize(configuration);
            DependencyInjectionSection.Initialize(configuration);
            RedisSection.Initialize(configuration);

            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            DbSession dbSession = new DbSession();

            dbSession.Database.EnsureCreated();

            this._unitOfWork = ResolveMediator.Resolve <IUnitOfWorkStub>();

            GlobalSetting.InitCurrentSessionId();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化依赖注入容器
        /// </summary>
        static void InitContainer()
        {
            IServiceCollection builder = ResolveMediator.GetServiceCollection();

            builder.RegisterConfigs();

            ResolveMediator.Build();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 初始化容器
 /// </summary>
 private void InitContainer()
 {
     if (!ResolveMediator.ContainerBuilt)
     {
         IServiceCollection builder = ResolveMediator.GetServiceCollection();
         builder.RegisterConfigs();
         ResolveMediator.Build();
     }
 }
Ejemplo n.º 4
0
        public void Init()
        {
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.AddTransient(typeof(IProductContract), typeof(ProductContract));

                ResolveMediator.Build();
            }
        }
Ejemplo n.º 5
0
        public void Init()
        {
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            ScheduleMediator.Clear();
        }
        /// <summary>
        /// 注册依赖注入解析者
        /// </summary>
        /// <param name="httpConfiguration">Http配置</param>
        public static void RegisterDependencyResolver(this HttpConfiguration httpConfiguration)
        {
            //初始化依赖注入容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            httpConfiguration.DependencyResolver = new WebApiDependencyResolver();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 创建服务建造者
        /// </summary>
        public IServiceCollection CreateBuilder(IServiceCollection services)
        {
            IServiceCollection builder = ResolveMediator.GetServiceCollection();

            foreach (ServiceDescriptor serviceDescriptor in services)
            {
                builder.Add(serviceDescriptor);
            }

            builder.RegisterConfigs();
            ResolveMediator.Build();

            return(builder);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 配置应用程序
        /// </summary>
        protected override void Configure()
        {
            //配置自动更新服务
            AutoUpdater.Start(FrameworkSection.Setting.AutoUpdateService.Value);

            //初始化依赖注入容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection serviceCollection = ResolveMediator.GetServiceCollection();
                serviceCollection.RegisterConfigs();
#if NETCOREAPP3_1_OR_GREATER
                serviceCollection.RegisterServiceModels();
#endif
                ResolveMediator.Build();
            }
        }
        public void Init()
        {
            //初始化依赖注入容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection serviceCollection = ResolveMediator.GetServiceCollection();
                serviceCollection.RegisterConfigs();
                ResolveMediator.Build();
            }

            DbSession dbSession = new DbSession(GlobalSetting.WriteConnectionString);

            dbSession.Database.CreateIfNotExists();

            this._unitOfWork = ResolveMediator.Resolve <IUnitOfWorkStub>();
        }
Ejemplo n.º 10
0
        public void Init()
        {
            //初始化配置文件
            Assembly      entryAssembly = Assembly.GetExecutingAssembly();
            Configuration configuration = ConfigurationExtension.GetConfigurationFromAssembly(entryAssembly);

            DependencyInjectionSection.Initialize(configuration);

            //初始化依赖注入容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }
        }
Ejemplo n.º 11
0
        public void Init()
        {
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            DbSession dbSession = new DbSession();

            dbSession.Database.CreateIfNotExists();

            this._unitOfWork = ResolveMediator.Resolve <IUnitOfWorkStub>();

            GlobalSetting.InitCurrentSessionId();
        }
        /// <summary>
        /// 适用依赖注入
        /// </summary>
        /// <param name="serviceDescription">服务描述</param>
        /// <param name="serviceHostBase">服务主机</param>
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            //初始化容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            foreach (ChannelDispatcherBase channelDispatcherBase in serviceHostBase.ChannelDispatchers)
            {
                ChannelDispatcher dispatcher = (ChannelDispatcher)channelDispatcherBase;
                foreach (EndpointDispatcher endpoint in dispatcher.Endpoints)
                {
                    if (!endpoint.IsSystemEndpoint)
                    {
                        endpoint.DispatchRuntime.InstanceProvider = new ServiceInstanceProvider(serviceDescription.ServiceType);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 配置应用程序
        /// </summary>
        protected override void Configure()
        {
            //初始化配置文件
            Assembly      entryAssembly = Assembly.GetExecutingAssembly();
            Configuration configuration = ConfigurationExtension.GetConfigurationFromAssembly(entryAssembly);

            ServiceModelSectionGroup.Initialize(configuration);
            FrameworkSection.Initialize(configuration);
            DependencyInjectionSection.Initialize(configuration);

            //初始化依赖注入容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection serviceCollection = ResolveMediator.GetServiceCollection();
                serviceCollection.RegisterConfigs();
                serviceCollection.RegisterServiceModels();
                serviceCollection.RegisterNavigationService();

                ResolveMediator.Build();
            }

            //初始化消息组件
            UserDialogs.Init(this);
        }