本文整理汇总了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;
}
示例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];
}
示例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>();
}
示例4: BuildUnityContainer
private static IUnityContainer BuildUnityContainer()
{
var container = new UnityContainer();
container.LoadConfiguration();
return container;
}
示例5: RegisterUnityContainer
private UnityContainer RegisterUnityContainer()
{
var container = new UnityContainer();
container.LoadConfiguration();
return container;
}
示例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));
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例10: Main
static void Main(string[] args)
{
IUnityContainer container = new UnityContainer();
container.LoadConfiguration();
var svc = container.Resolve<IMessageService>();
svc.SendMessage("Michael", "Hello!");
}
示例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);
}
示例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 );
}
示例13: CachingService
static CachingService()
{
var section = (UnityConfigurationSection) ConfigurationManager.GetSection("unity.caching");
IUnityContainer container = new UnityContainer();
container.LoadConfiguration(section);
Store = container.Resolve<ICachingService>();
}
示例14: Application_Start
protected void Application_Start(object sender, EventArgs e)
{
IUnityContainer applicationContainer = new UnityContainer();
applicationContainer.LoadConfiguration("application");
ApplicationContainer = applicationContainer;
}
示例15: ResolveReferences
private void ResolveReferences()
{
using (var container = new UnityContainer())
{
container.LoadConfiguration();
this.ResolveReferences(container);
}
}