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


C# UnityContainer.LoadConfiguration方法代码示例

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


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

示例1: BuildContainer

        /// <summary>
        /// Build 
        /// </summary>
        public static IUnityContainer BuildContainer()
        {
            var pinkoContainer = new UnityContainer();

            Trace.Listeners.Add(new TraceListenerDebug());

            //pinkoContainer.RegisterInstance<IPinkoConfiguration>(pinkoContainer.Resolve<PinkoConfiguration>());
            //pinkoContainer.RegisterInstance<IPinkoApplication>(pinkoContainer.Resolve<PinkoApplication>());
            ////pinkoContainer.RegisterInstance<ICloudConfigurationManager>(pinkoContainer.Resolve<AzureCloudConfigurationManager>());

            //pinkoContainer.RegisterInstance<IMessageHandlerManager>(pinkoContainer.Resolve<MessageHandlerManager>().Initialize()); // Handle messages

            //pinkoContainer.RegisterInstance<IBusMessageServer>(pinkoContainer.Resolve<AzureBusMessageServer>());
            ////pinkoContainer.RegisterInstance<IBusMessageServer>(pinkoContainer.Resolve<InMemoryBusMessageServer>().Initialize()); // when running offline
            //pinkoContainer.RegisterInstance<IBusMessageServer>(pinkoContainer.Resolve<MsMqBusMessageServer>().Initialize()); // when running offline

            if (ConfigurationManager.GetSection("unity") != null)
                pinkoContainer.LoadConfiguration();

            //            Microsoft.Practices.Unity.Configuration.UnityConfigurationSection

            //// Load unity config file
            //var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = "PinkoCommon.dll.config" };
            //var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            //var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");
            //pinkoContainer.LoadConfiguration(unitySection);

            pinkoContainer.RegisterInstance<IRxMemoryBus<IBusMessageOutbound>>(pinkoContainer.Resolve<IPinkoApplication>().GetBus<IBusMessageOutbound>());

            return pinkoContainer;
        }
开发者ID:cotmechy,项目名称:PinkoAzure,代码行数:34,代码来源:CommonContainerManager.cs

示例2: GetCities

        public CascadingDropDownNameValue[] GetCities(string knownCategoryValues, string category)
        {
            var container = new UnityContainer();
            container.LoadConfiguration();

            StringDictionary ddlStateData = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            int state = Convert.ToInt32(ddlStateData["State"]);

            if (state > 0)
            {
                var cityBiz = container.Resolve<Business.ICity>();
                var cities = cityBiz.Query(c => c.State.Id == state, "State");

                List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();

                foreach (var item in cities)
                {
                    values.Add(new CascadingDropDownNameValue(item.Name, item.Id.ToString()));
                }

                return values.ToArray();
            }

            return new CascadingDropDownNameValue[0];
        }
开发者ID:batera74,项目名称:mordomo,代码行数:25,代码来源:LoadFormData.asmx.cs

示例3: GetRepository

        public static IRepository GetRepository(string containerName)
        {
            //specify the file path
            string configName = String.Format(@"{0}/unity.config", System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath);
            var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = configName };
            Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
            var unitySection = (UnityConfigurationSection)configuration.GetSection("unity");

            var container = new UnityContainer();
            if (String.IsNullOrEmpty(containerName))
                container.LoadConfiguration(unitySection);
            else
                container.LoadConfiguration(unitySection,containerName);

            return container.Resolve<IRepository>();
        }
开发者ID:jerry82,项目名称:WcfTodo,代码行数:16,代码来源:Utils.cs

示例4: BuildUnityContainer

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();
            container.LoadConfiguration();

            return container;
        }
开发者ID:jesusmoreno85,项目名称:LoginTestApp,代码行数:7,代码来源:Bootstrapper.cs

示例5: RegisterUnityContainer

        private UnityContainer RegisterUnityContainer()
        {
            var container = new UnityContainer();
            container.LoadConfiguration();

            return container;
        }
开发者ID:fanshu,项目名称:CoursewareDI,代码行数:7,代码来源:Global.asax.cs

示例6: Main

        public static void Main(string[] args)
        {
            var diContainer = new UnityContainer();

            diContainer.LoadConfiguration();

            var source = diContainer.Resolve<ISnapshotSource>();

            while (true)
            {
                Console.WriteLine("Retrieving snapshots...");

                var snapshots = source.GetSnapshots();

                Parallel.ForEach(snapshots, snapshot =>
                {
                    var handler = diContainer.Resolve<ISnapshotSink>();

                    Console.WriteLine("Writing snapshot...");

                    handler.HandleSnapshot(snapshot);
                });

                Console.WriteLine("Sleeping...");

                Thread.Sleep(TimeSpan.FromSeconds(30));
            }
        }
开发者ID:jplane,项目名称:TheMartaBus.AzureServiceFabric,代码行数:28,代码来源:Program.cs

示例7: Main

        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (IUnityContainer container = new UnityContainer())
            {
                container.LoadConfiguration();

                container
                    .RegisterType(
                        typeof(IRepository<>),
                        typeof(ValidatingRepository<>),
                        "validating")
                    .RegisterType<IValidator<StockQuote>, RandomStockQuoteValidator>()
                    .RegisterType<ILogger, CompositeLogger>(
                        "composite",
                        new InjectionConstructor(
                            new ResolvedArrayParameter<ILogger>(
                                typeof(ILogger),
                                new ResolvedParameter<ILogger>("UI"))));

                StocksTickerPresenter presenter
                    = container.Resolve<StocksTickerPresenter>(
                        new ParameterOverride(
                            "repository",
                            new ResolvedParameter<IRepository<StockQuote>>("validating")).OnType<StocksTickerPresenter>(),
                        new PropertyOverride("Logger", new ResolvedParameter<ILogger>("composite")));

                Application.Run((Form)presenter.View);
            }
        }
开发者ID:kanpinar,项目名称:unity3.1th,代码行数:32,代码来源:Program.cs

示例8: UnityInstanceProvider

        public UnityInstanceProvider(Type contractType, string containerName)
        {
            if (contractType == null)
            {
                throw new ArgumentNullException("contractType");

            }
            this._contractType = contractType;

            string key = containerName ?? "";
            if (Containers.ContainsKey(key))
            {
                this.Container = Containers[key];
                return;
            }
            IUnityContainer container = new UnityContainer();
            container.LoadConfiguration(containerName);
            lock (syncHelper)
            {
                if (!Containers.ContainsKey(key))
                {
                    Containers[key] = container;
                }
            }

            Container = container;
        }
开发者ID:dishiyicijinqiu,项目名称:OneCardAccess,代码行数:27,代码来源:UnityInstanceProvider.cs

示例9: BuildUnityContainer

        private static IUnityContainer BuildUnityContainer()
        {
            UnityContainer tempContainer = null;
            UnityContainer container;

            try
            {
                tempContainer = new UnityContainer();

                // Register your container mappings in the config file.
                // It will get loaded into the container with the following call:
                tempContainer.LoadConfiguration();

                container = tempContainer;
                tempContainer = null;
            }
            finally
            {
                if (tempContainer != null)
                {
                    tempContainer.Dispose();
                }
            }

            return container;
        }
开发者ID:sendtorakesh,项目名称:MitchellClaim,代码行数:26,代码来源:Bootstrapper.cs

示例10: Main

 static void Main(string[] args)
 {
     IUnityContainer container = new UnityContainer();
     container.LoadConfiguration();
     var svc = container.Resolve<IMessageService>();
     svc.SendMessage("Michael", "Hello!");
 }
开发者ID:showu9527,项目名称:di-book-support,代码行数:7,代码来源:Program.cs

示例11: ApiSetup

        static ApiSetup()
        {
            try
            {

                //Create
                Container = new UnityContainer();
                Locator = new UnityServiceLocator(Container);
                //Add entlib extensions
                Container.AddNewExtension<EnterpriseLibraryCoreExtension>();
#pragma warning disable 612,618
                Container.AddNewExtension<CachingBlockExtension>();
#pragma warning restore 612,618
                ServiceLocator.SetLocatorProvider(() => Locator);
                Container.LoadConfiguration("api");
                ApiDefaultConfig.DoDefaultRegistrations(Container);
                //NOTE: disabled for now
                //try
                //{
                //    ApiDefaultConfig.DoAutomaticConfiguration(Container);
                //    Initialization.Add(ApiSetupState.UnityAutoRegitrations, null);
                //}
                //catch (Exception e)
                //{
                //    Initialization.Add(ApiSetupState.UnityAutoRegitrations, new[] { e });
                //}
            }
            catch (Exception e)
            {
                Initialization.Add(ApiSetupState.UnityRegitrations, new[] { e });
                throw;
            }
            Initialization.Add(ApiSetupState.UnityRegitrations, null);
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:34,代码来源:ApiSetup.cs

示例12: PostStart

		/// <summary>
		///     Initializes the unity container when the application starts up.
		/// </summary>
		/// <remarks>
		///		Do not edit this method. Perform any modifications in the
		///		<see cref="RegisterDependencies" /> method.
		/// </remarks>
		internal static void PostStart()
		{
			IUnityContainer container = new UnityContainer();
			HttpContext.Current.Application.SetContainer( container );
            container.LoadConfiguration();
			RegisterDependencies( container );
		}
开发者ID:MilagrosGonzales,项目名称:Proy1.Programacion,代码行数:14,代码来源:UnityWebFormsStart.cs

示例13: CachingService

 static CachingService()
 {
     var section = (UnityConfigurationSection) ConfigurationManager.GetSection("unity.caching");
     IUnityContainer container = new UnityContainer();
     container.LoadConfiguration(section);
     Store = container.Resolve<ICachingService>();
 }
开发者ID:nhcloud,项目名称:azureredis,代码行数:7,代码来源:CachingService.cs

示例14: Application_Start

        protected void Application_Start(object sender, EventArgs e)
        {
            IUnityContainer applicationContainer = new UnityContainer();
            applicationContainer.LoadConfiguration("application");

            ApplicationContainer = applicationContainer;
        }
开发者ID:kanpinar,项目名称:unity3.1th,代码行数:7,代码来源:Global.asax.cs

示例15: ResolveReferences

 private void ResolveReferences()
 {
     using (var container = new UnityContainer())
     {
         container.LoadConfiguration();
         this.ResolveReferences(container);
     }
 }
开发者ID:umebayashi,项目名称:workshop,代码行数:8,代码来源:BaseWorkerService.cs


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