예제 #1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            AutoRegister.AllInMvc(new UnityContainer());
        }
예제 #2
0
파일: Startup.cs 프로젝트: kuroblog/WebAPI
        // 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>();
        }
예제 #3
0
        /// <summary>
        /// 通过程序集自动注入
        /// </summary>
        public static void AssemblyRun()
        {
            var serviceProvider = new AutoRegister().Build();
            var person          = serviceProvider.GetService <IPerson>();

            person.Introduction();
            Console.ReadKey();
        }
        //注入系统基础设施
        public static IServiceCollection AddMiniBlogBase(this IServiceCollection services)
        {
            //每次请求只创建一次
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            //注入仓储
            services.AddTransient(typeof(IRepository <,>), typeof(Repository <,>));
            //自动注入是服务层
            var registers = AutoInjection.RegisterType();

            foreach (var item in registers)
            {
                services.AddTransient(item.itype, item.type);
            }
            //自动注入映射
            services.AddAutoMapper(AutoRegister.RegisterType());
            return(services);
        }
예제 #5
0
        /// <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();
        }
예제 #6
0
        public static void SaveSettings(string Path)
        {
            XmlDocument Xml = new XmlDocument();

            Xml.AppendChild(Xml.CreateNode(XmlNodeType.Element, "settings", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "UserName", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Password", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Domain", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Host", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Port", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "AutoRegister", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "AutoAnswer", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "DoNotDisturb", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Prefix0", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "CallForm", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "PlaySound", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "Ringtone", ""));
            Xml.SelectSingleNode("settings").AppendChild(Xml.CreateNode(XmlNodeType.Element, "PipeName", ""));

            Xml.SelectSingleNode("settings/UserName").InnerText     = UserName;
            Xml.SelectSingleNode("settings/Password").InnerText     = Password;
            Xml.SelectSingleNode("settings/Domain").InnerText       = Domain;
            Xml.SelectSingleNode("settings/Host").InnerText         = Host;
            Xml.SelectSingleNode("settings/Port").InnerText         = Port.ToString();
            Xml.SelectSingleNode("settings/AutoRegister").InnerText = AutoRegister.ToString();
            Xml.SelectSingleNode("settings/AutoAnswer").InnerText   = AutoAnswer.ToString();
            Xml.SelectSingleNode("settings/DoNotDisturb").InnerText = DoNotDisturb.ToString();
            Xml.SelectSingleNode("settings/Prefix0").InnerText      = Prefix0.ToString();
            Xml.SelectSingleNode("settings/CallForm").InnerText     = CallForm.ToString();
            Xml.SelectSingleNode("settings/PlaySound").InnerText    = PlaySound.ToString();
            Xml.SelectSingleNode("settings/Ringtone").InnerText     = Ringtone;
            Xml.SelectSingleNode("settings/PipeName").InnerText     = PipeName;

            if (Path == "")
            {
                Xml.Save(Globals.PathSettings);
            }
            else
            {
                Xml.Save(Path);
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            var c = new UnityContainer();

            AutoRegister.All(c);
            //AutoRegister.All() perform  the following on each object with the "Implement"
            //attribute.

            //c.RegisterType(typeof (IUserService), typeof (UserService));


            var service = c.Resolve <UserViewModel>();

            if (service.Authorize("test", "test"))
            {
                Console.WriteLine("OK");
            }

            Console.ReadLine();
        }
 static ResourceProviderManager()
 {
     AutoRegister.Load(Assembly.GetExecutingAssembly());
 }
예제 #9
0
 static PluginManager()
 {
     AutoRegister.Load(Assembly.GetExecutingAssembly());
 }