/// <summary> /// 初始化,必须先调用 /// </summary> public static void InitializeBase(bool bear) { if (IsInitialize) { return; } IocHelper.Update(); IocHelper.AddScoped <GlobalContext, BusinessContext>(); IocHelper.AddSingleton <IZeroPublisher, ZeroNetBridge>(); IocHelper.AddSingleton <IGlobalContext, BusinessContext>(p => BusinessContext.Context); IocHelper.Update(); Environment.CurrentDirectory = ConfigurationManager.BasePath = HttpContext.Current.Server.MapPath("~"); LogRecorder.Initialize(); LogRecorder.SystemLog("启动"); LogRecorder.GetRequestIdFunc = () => RandomOperate.Generate(8); GlobalConfiguration.Configuration.MapHttpAttributeRoutes(new CustomDirectRouteProvider()); HttpHandler.Handlers.Add(new CorsHandler()); HttpHandler.Handlers.Add(new HttpIoLogHandler()); if (bear) { HttpHandler.Handlers.Add(new BearerHandler()); } IsInitialize = true; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { #region standard api services.AddOptions(); services.Configure <HospProxySettings>(Configuration.GetSection(nameof(HospProxySettings))); services.AddScoped <ITestService, TestService>(); //IocHelper.AddScoped<IHospProxyService, HospWebProxyService>(); //IocHelper.AddScoped<IProxyService, ProxyService>(); #endregion services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); #region zmq api IocHelper.ServiceCollection.Configure <HospProxySettings>(Configuration.GetSection(nameof(HospProxySettings))); IocHelper.AddScoped <ITestService, TestService>(); IocHelper.AddScoped <IHospProxyService, HospWebProxyService>(); IocHelper.AddScoped <IProxyService, ProxyService>(); ZeroApplication.Initialize(); var iar = new AutoRegister(); iar.Initialize(); iar.AutoRegist(); #endregion }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { #region iochelper IocHelper.ServiceCollection.Configure <HisOptions>(Configuration.GetSection(nameof(HisOptions))); IocHelper.AddScoped <IHisProxyInterface, HisSocketProxy>(); IocHelper.AddScoped <IHisProxyInterface, HisWebSvcProxy>(); IocHelper.AddScoped <ProxyFactory>(); IocHelper.AddScoped <IProxyService, ProxyService>(); ZeroApplication.Initialize(); #endregion #region standard //services.AddOptions(); //services.Configure<HisOptions>(Configuration.GetSection(nameof(HisOptions))); //services.AddScoped<IHisProxyInterface, HisSocketProxy>(); //services.AddScoped<IHisProxyInterface, HisWebSvcProxy>(); //services.AddScoped<ProxyFactory>(); //services.AddScoped<IProxyService, ProxyService>(); #endregion var i = new AutoRegister() as IAutoRegister; i.Initialize(); i.AutoRegist(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); //services.AddScoped<IFoo, Foo>(); }
/// <summary> /// 内部构造 /// </summary> public static GlobalContext Reset() { if (Local.Value != null && !Local.Value.IsDisposed) { Local.Value.Dispose(); } Local.Value = IocHelper.Create <GlobalContext>(); if (Local.Value != null) { return(Local.Value); } IocHelper.AddScoped <GlobalContext, GlobalContext>(); Local.Value = IocHelper.Create <GlobalContext>(); return(Local.Value); }
/// <summary> /// /// </summary> /// <param name="services"></param> /// <remarks>This method gets called by the runtime. Use this method to add services to the container.</remarks> public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); IocHelper.ServiceCollection.Configure <HospProxySettings>(Configuration.GetSection(nameof(HospProxySettings))); IocHelper.AddScoped <IHospProxyInterface, HisSocketProxy>(); IocHelper.AddScoped <IHospProxyInterface, HisWebSvcProxy>(); IocHelper.AddScoped <HisProxyFactory>(); IocHelper.AddScoped <IProxyService, ProxyService>(); ZeroApplication.Initialize(); IAutoRegister iar = new AutoRegister(); iar.Initialize(); iar.AutoRegist(); }
/// <summary> /// 内部构造 /// </summary> public static GlobalContext Reset() { if (_local == null) { _local = new AsyncLocal <GlobalContext>(); } else if (_local.Value != null && !_local.Value.IsDisposed) { _local.Value.Dispose(); } _local.Value = IocHelper.Create <GlobalContext>(); if (_local.Value != null) { return(_local.Value); } IocHelper.AddScoped <GlobalContext, GlobalContext>(); _local.Value = IocHelper.Create <GlobalContext>(); return(_local.Value); }