当前位置: 首页>>代码示例>>C#>>正文


C# IUnityContainer.LoadConfiguration方法代码示例

本文整理汇总了C#中IUnityContainer.LoadConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C# IUnityContainer.LoadConfiguration方法的具体用法?C# IUnityContainer.LoadConfiguration怎么用?C# IUnityContainer.LoadConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUnityContainer的用法示例。


在下文中一共展示了IUnityContainer.LoadConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RegisterConfig

		private static void RegisterConfig(IUnityContainer container)
		{
			if (ConfigurationManager.GetSection("unity") != null)
			{
				container.LoadConfiguration();
			}
		}
开发者ID:smartpcr,项目名称:bigdata2,代码行数:7,代码来源:UnityConfig.cs

示例2: RegisterTypes

        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            container.LoadConfiguration();

            // Register your types here
        }
开发者ID:WalkingDonkey,项目名称:HotChat,代码行数:11,代码来源:UnityConfig.cs

示例3: Main

        private static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                return;
            }

            Container = new UnityContainer();
            Container.LoadConfiguration("agent");

            // TODO: this is a hack. review it later.
            var store = Container.Resolve<ObjectStore>();
            store.Add(new SysDescr());
            store.Add(new SysObjectId());
            store.Add(new SysUpTime());
            store.Add(new SysContact());
            store.Add(new SysName());
            store.Add(new SysLocation());
            store.Add(new SysServices());
            store.Add(new SysORLastChange());
            store.Add(new SysORTable());
            
            var users = Container.Resolve<UserRegistry>();
            users.Add(new OctetString("neither"), DefaultPrivacyProvider.DefaultPair);
            users.Add(new OctetString("authen"), new DefaultPrivacyProvider(new MD5AuthenticationProvider(new OctetString("authentication"))));
            users.Add(new OctetString("privacy"), new DESPrivacyProvider(new OctetString("privacyphrase"),
                                                                         new MD5AuthenticationProvider(new OctetString("authentication"))));
            
            ToolStripManager.Renderer = new Office2007Renderer.Office2007Renderer();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }   
开发者ID:xxjeng,项目名称:nuxleus,代码行数:33,代码来源:Program.cs

示例4: Initialize

 static void Initialize()
 {
     _container = new UnityContainer();
     //_container.RegisterType<IDbContext, RCDB>(new HierarchicalLifetimeManager());
     //_container.RegisterType<IRCIdentityService, RCIdentityService>(new HierarchicalLifetimeManager());
     _container.LoadConfiguration();
 }
开发者ID:vadpetrov,项目名称:Pluralsight,代码行数:7,代码来源:IocContainer.cs

示例5: UnityControllerFactory

 public UnityControllerFactory(string configFile,string containerName = "")
 {
     try
     {
         UnityConfigurationSection unityConfigurationSection = null;
         var fileMap = new System.Configuration.ExeConfigurationFileMap { ExeConfigFilename = configFile };
         System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, System.Configuration.ConfigurationUserLevel.None);
         if (!string.IsNullOrEmpty(containerName))
         {
             unityConfigurationSection = (UnityConfigurationSection)configuration.GetSection(containerName);
         }
         else
         {
             unityConfigurationSection = (UnityConfigurationSection)configuration.GetSection("unity");
         }
         if (null == unityConfigurationSection)
         {
             throw new ConfigurationErrorsException("Cannot find <unity> configuration section");
         }
         Container = new UnityContainer();
         Container.LoadConfiguration(unityConfigurationSection);
     }
     catch(Exception ex)
     {
         LogUtil.Exception("IocLogger", ex);
     }
 }
开发者ID:zsjforgithub,项目名称:usp-zsj-01-15,代码行数:27,代码来源:UnityControllerFactory.cs

示例6: Initialise

        public static void Initialise(IUnityContainer UnityContainer)
        {
            UnityContainer.LoadConfiguration();

            // Registering interfaces of Unit Of Work & Generic Repository
            UnityContainer.RegisterType(typeof(IRepository<>), typeof(Repository<>));
            UnityContainer.RegisterType<IUnitOfWork, UnitOfWork>();

            UnityContainer.RegisterType<MyDataContextConfiguration>(new InjectionConstructor(ApplicationConfig.ConnectionString, ApplicationConfig.InitDatabase));
            UnityContainer.RegisterType<DbContext>(new InjectionFactory(con => con.Resolve<MyDataContext>()));

            UnityContainer.RegisterInstance(UnityContainer.Resolve<DbContext>(), new PerThreadLifetimeManager());

            UnityContainer.RegisterType<IEmployeeService, EmployeeService>();
            UnityContainer.RegisterType<IProductService, ProductService>();
            UnityContainer.RegisterType<ICompanyService, CompanyService>();
            UnityContainer.RegisterType<ICountryService, CountryService>();
            UnityContainer.RegisterType<IMainCompanyService, MainCompanyService>();
            UnityContainer.RegisterType<IFunctionService, FunctionService>();
            UnityContainer.RegisterType<ISubFunctionService, SubFunctionService>();
            UnityContainer.RegisterType<IOUService, OUService>();
            UnityContainer.RegisterType<IUserService, UserService>();
            UnityContainer.RegisterType<IRoleService, RoleService>();
            UnityContainer.RegisterType<IUserRoleService, UserRoleService>();

            DependencyResolver.SetResolver(new UnityDependencyResolver(UnityContainer));
        }
开发者ID:jumolano,项目名称:KendoGridBinderEx,代码行数:27,代码来源:UnityMVCBootstrapper.cs

示例7: RegisterTypes

 /// <summary>Registers the type mappings with the Unity container.</summary>
 /// <param name="container">The unity container to configure.</param>
 /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
 /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
 public static void RegisterTypes(IUnityContainer container)
 {
     // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
     container.LoadConfiguration("defaultContainer");
      ReportFactory.Instance = container.Resolve<ReportFactory>();
     // TODO: Register your types here
     // container.RegisterType<IProductRepository, ProductRepository>();
 }
开发者ID:ibcLee,项目名称:Wttech.DataSubmitted,代码行数:12,代码来源:UnityConfig.cs

示例8: ConstructorInjectionWithConfigurationFromXMLTest

        public void ConstructorInjectionWithConfigurationFromXMLTest()
        {
            _container = new UnityContainer();
            _container.LoadConfiguration();

            var objectWithInjection = _container.Resolve<SomeClass>();

            Assert.AreEqual(SIMPLE_INJECTION_CANDIDATE, objectWithInjection.GetNameOfInjectedCandidate());
        }
开发者ID:dfensgmbh,项目名称:biz.dfch.CS.Unity.Example,代码行数:9,代码来源:XMLContainerConfigurationTest.cs

示例9: BuildUnityContainer

 public static IUnityContainer BuildUnityContainer()
 {
     if (container == null)
     { 
         container = new UnityContainer();
         container.LoadConfiguration();
     }
     return container;
 }
开发者ID:Vinzz,项目名称:SwitchWifi2,代码行数:9,代码来源:UnityResolver.cs

示例10: RegisterTypes

 /// <summary>Registers the type mappings with the Unity container.</summary>
 /// <param name="container">The unity container to configure.</param>
 /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
 /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
 public static void RegisterTypes(IUnityContainer container)
 {
     // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
     // container.LoadConfiguration();
     container.LoadConfiguration("defaultContainer");
     BootstrapMvc2015GitHub.Framework.UnityInstance.Instance.Container = container;
     // TODO: Register your types here
     // container.RegisterType<IProductRepository, ProductRepository>();
 }
开发者ID:caowujun,项目名称:BootstrapMvc2015GitHub,代码行数:13,代码来源:UnityConfig.cs

示例11: LoadConfig

 public static void LoadConfig(IUnityContainer container)
 {
     string configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"QualityReport\Web.config");
     if (!File.Exists(configFile))
     {
         configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\QualityReport\Web.config");
     }
     container.LoadConfiguration(GetConfigurationSection(configFile));
 }
开发者ID:ryansecret,项目名称:reprostservice,代码行数:9,代码来源:QualityReportServiceFactory.cs

示例12: ConfigureUnity

        private void ConfigureUnity()
        {
            Container = new UnityContainer();
            Container.LoadConfiguration();
            UnityServiceLocator locator = new UnityServiceLocator(Container);

            ServiceLocator.SetLocatorProvider(() => locator);

            ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory(Container));
        }
开发者ID:Sirix,项目名称:NProject2,代码行数:10,代码来源:Global.asax.cs

示例13: RegisterTypes

        private static void RegisterTypes(IUnityContainer container)
        {
            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
            container.LoadConfiguration(section);

            //  Register web security
            container.RegisterInstance((IWebSecurity)new WebSecurityWrapper());
            // create bean programatically instead of using xml
            container.RegisterInstance((IDiscountService)new DiscountService());
            container.RegisterInstance((IManageUserService)new ManageUserService());
            container.RegisterInstance((IManageStoreService)new ManageStoreService());
        }
开发者ID:egreene,项目名称:PracticeGDVP,代码行数:12,代码来源:UnityConfiguration.cs

示例14: RegisterTypes

        /// <summary>Registers the type mappings with the Unity container.</summary>
        /// <param name="container">The unity container to configure.</param>
        /// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to 
        /// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
        public static void RegisterTypes(IUnityContainer container)
        {
            // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
            container.LoadConfiguration();

            // TODO: Register your types here
            // container.RegisterType<IProductRepository, ProductRepository>();

            container.RegisterInstance<TimeSpan>("Kanae:RetentionTimeSpan", ApplicationConfig.Current.RetentionTimeSpan);

            // ServiceLocator をセットする
            ServiceLocator.SetLocatorProvider(() => new UnityServiceLocator(container));
        }
开发者ID:gogosub77,项目名称:Kanae,代码行数:17,代码来源:UnityConfig.cs

示例15: RegisterTypes

        public static void RegisterTypes(IUnityContainer container) {
            container.LoadConfiguration();

            //对全局异常处理程序自注入
            //container.RegisterType<ExceptionLogAttribute, ExceptionLogAttribute>();

            var conv = new Convention(container,
                typeof(BaseBiz).Assembly,
                typeof(TemplateServiceImpl).Assembly,
                Assembly.GetExecutingAssembly()
                );

            container.RegisterTypes(conv);
        }
开发者ID:gruan01,项目名称:MessageCenter,代码行数:14,代码来源:UnityConfig.cs


注:本文中的IUnityContainer.LoadConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。