本文整理汇总了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();
}
}
示例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
}
示例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());
}
示例4: Initialize
static void Initialize()
{
_container = new UnityContainer();
//_container.RegisterType<IDbContext, RCDB>(new HierarchicalLifetimeManager());
//_container.RegisterType<IRCIdentityService, RCIdentityService>(new HierarchicalLifetimeManager());
_container.LoadConfiguration();
}
示例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);
}
}
示例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));
}
示例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>();
}
示例8: ConstructorInjectionWithConfigurationFromXMLTest
public void ConstructorInjectionWithConfigurationFromXMLTest()
{
_container = new UnityContainer();
_container.LoadConfiguration();
var objectWithInjection = _container.Resolve<SomeClass>();
Assert.AreEqual(SIMPLE_INJECTION_CANDIDATE, objectWithInjection.GetNameOfInjectedCandidate());
}
示例9: BuildUnityContainer
public static IUnityContainer BuildUnityContainer()
{
if (container == null)
{
container = new UnityContainer();
container.LoadConfiguration();
}
return container;
}
示例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>();
}
示例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));
}
示例12: ConfigureUnity
private void ConfigureUnity()
{
Container = new UnityContainer();
Container.LoadConfiguration();
UnityServiceLocator locator = new UnityServiceLocator(Container);
ServiceLocator.SetLocatorProvider(() => locator);
ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory(Container));
}
示例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());
}
示例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));
}
示例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);
}