本文整理汇总了C#中IIocManager类的典型用法代码示例。如果您正苦于以下问题:C# IIocManager类的具体用法?C# IIocManager怎么用?C# IIocManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IIocManager类属于命名空间,在下文中一共展示了IIocManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test_Way_3
private static void Test_Way_3(IIocManager iocManager)
{
iocManager.Using<Tester>(tester =>
{
tester.Test();
});
}
示例2: Initialize
public static void Initialize(IIocManager manager,List<Assembly> assemblys)
{
assemblys.ForEach(m =>
{
////多实例
//manager.IocContainer.Register(
// Classes.FromAssembly(m)
// .IncludeNonPublicTypes()
// .BasedOn<IMultipleDependency>()
// .WithService.Self()
// .WithService.DefaultInterfaces()
// .LifestyleTransient()
// );
////单例
//manager.IocContainer.Register(
// Classes.FromAssembly(m)
// .IncludeNonPublicTypes()
// .BasedOn<ISingleDependency>()
// .WithService.Self()
// .WithService.DefaultInterfaces()
// .LifestyleSingleton()
// );
////拦截器
//manager.IocContainer.Register(
// Classes.FromAssembly(m)
// .IncludeNonPublicTypes()
// .BasedOn<IInterceptor>()
// .WithService.Self()
// .LifestyleTransient()
// );
Registrants.ForEach(r => r(m));
});
}
示例3: AbpNHibernateInterceptor
public AbpNHibernateInterceptor(IIocManager iocManager)
{
_iocManager = iocManager;
_abpSession =
new Lazy<IAbpSession>(
() => _iocManager.IsRegistered(typeof(IAbpSession))
? _iocManager.Resolve<IAbpSession>()
: NullAbpSession.Instance,
isThreadSafe: true
);
_guidGenerator =
new Lazy<IGuidGenerator>(
() => _iocManager.IsRegistered(typeof(IGuidGenerator))
? _iocManager.Resolve<IGuidGenerator>()
: SequentialGuidGenerator.Instance,
isThreadSafe: true
);
_eventBus =
new Lazy<IEventBus>(
() => _iocManager.IsRegistered(typeof(IEventBus))
? _iocManager.Resolve<IEventBus>()
: NullEventBus.Instance,
isThreadSafe: true
);
}
示例4: AbpModuleManager
public AbpModuleManager(IIocManager iocManager, IModuleFinder moduleFinder)
{
_modules = new AbpModuleCollection();
_iocManager = iocManager;
_moduleFinder = moduleFinder;
Logger = NullLogger.Instance;
}
示例5: DefaultModuleManager
public DefaultModuleManager(IIocManager iocManager, IModuleFinder moduleFinder, IConfigurationManager configurationManager)
{
_modules = new ModuleCollection();
_iocManager = iocManager;
_moduleFinder = moduleFinder;
_configurationManager = configurationManager;
}
示例6: PermissionManager
/// <summary>
/// Constructor.
/// </summary>
public PermissionManager(IIocManager iocManager, IAuthorizationConfiguration authorizationConfiguration)
{
_iocManager = iocManager;
_authorizationConfiguration = authorizationConfiguration;
AbpSession = NullAbpSession.Instance;
}
示例7: RegisterForDbContext
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager)
{
foreach (var entityType in dbContextType.GetEntityTypes())
{
foreach (var interfaceType in entityType.GetInterfaces())
{
if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity<>))
{
var primaryKeyType = interfaceType.GenericTypeArguments[0];
if (primaryKeyType == typeof(Guid))
{
var genericRepositoryType = typeof(IRepository<>).MakeGenericType(entityType);
if (!iocManager.IsRegistered(genericRepositoryType))
{
iocManager.Register(
genericRepositoryType,
typeof(EfRepositoryBase<,>).MakeGenericType(dbContextType, entityType),
DependencyLifeStyle.Transient
);
}
}
var genericRepositoryTypeWithPrimaryKey = typeof(IRepository<,>).MakeGenericType(entityType, primaryKeyType);
if (!iocManager.IsRegistered(genericRepositoryTypeWithPrimaryKey))
{
iocManager.Register(
genericRepositoryTypeWithPrimaryKey,
typeof(EfRepositoryBase<,,>).MakeGenericType(dbContextType, entityType, primaryKeyType),
DependencyLifeStyle.Transient
);
}
}
}
}
}
示例8: Test_Way_2
private static void Test_Way_2(IIocManager iocManager)
{
using (var tester = iocManager.ResolveAsDisposable<Tester>())
{
tester.Object.Test();
}
}
示例9: LanguageManagementConfig
public LanguageManagementConfig(IIocManager iocManager, IAbpStartupConfiguration configuration)
{
_iocManager = iocManager;
_configuration = configuration;
Logger = NullLogger.Instance;
}
示例10: RegisterForDbContext
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager)
{
var autoRepositoryAttr = dbContextType.GetSingleAttributeOrNull<AutoRepositoryTypesAttribute>();
if (autoRepositoryAttr == null)
{
autoRepositoryAttr = AutoRepositoryTypesAttribute.Default;
}
foreach (var entityType in dbContextType.GetEntityTypes())
{
var genericRepositoryType = autoRepositoryAttr.RepositoryInterface.MakeGenericType(entityType);
if (!iocManager.IsRegistered(genericRepositoryType))
{
var implType = autoRepositoryAttr.RepositoryImplementation.GetGenericArguments().Length == 1
? autoRepositoryAttr.RepositoryImplementation.MakeGenericType(entityType)
: autoRepositoryAttr.RepositoryImplementation.MakeGenericType(dbContextType, entityType);
iocManager.Register(
genericRepositoryType,
implType,
DependencyLifeStyle.Multiple
);
}
}
}
示例11: AbpModuleManager
public AbpModuleManager(IIocManager iocManager, IAbpPlugInManager abpPlugInManager)
{
_modules = new AbpModuleCollection();
_iocManager = iocManager;
_abpPlugInManager = abpPlugInManager;
Logger = NullLogger.Instance;
}
示例12: RegisterForDbContext
public static void RegisterForDbContext(Type dbContextType, IIocManager iocManager)
{
var repositoryType = dbContextType.Assembly.GetTypes().Where(type => !string.IsNullOrEmpty(type.Namespace))
.Where(type => type.BaseType != null && type.BaseType.IsGenericType && (type.BaseType.GetGenericTypeDefinition() == typeof(IRepository<>) || type.BaseType.GetGenericTypeDefinition() == typeof(IRepository<,>) || type.BaseType.GetGenericTypeDefinition() == typeof(EfRepositoryBase<,>) || type.BaseType.GetGenericTypeDefinition() == typeof(EfRepositoryBase<,,>)));
foreach (var entityType in dbContextType.GetEntityTypes())//从dataset中获取所有的实体
{
foreach (var interfaceType in entityType.GetInterfaces())//获取所有实体实现的接口
{
if (interfaceType.IsGenericType && interfaceType.GetGenericTypeDefinition() == typeof(IEntity<>))
{
var primaryKeyType = interfaceType.GenericTypeArguments[0];//获取所有的实体的主键
foreach (var maprepositoryType in repositoryType)
{
if (!iocManager.IsRegistered(maprepositoryType))
{
var implType = maprepositoryType.GetGenericArguments().Length == 2
? maprepositoryType.MakeGenericType(entityType, primaryKeyType)
: maprepositoryType.MakeGenericType(dbContextType, entityType, primaryKeyType);
iocManager.Register(
maprepositoryType,
implType,
DependencyLifeStyle.Transient
);
}
}
}
}
}
}
示例13: Test_Way_1
private static void Test_Way_1(IIocManager iocManager)
{
var tester = iocManager.Resolve<Tester>();
tester.Test();
iocManager.Release(tester);
}
示例14: UnitOfWorkManager
public UnitOfWorkManager(
IIocManager iocManager,
IUnitOfWorkProvider currentUnitOfWorkProvider,
IUnitOfWorkDefaultOptions defaultOptions)
{
_iocManager = iocManager;
_currentUnitOfWorkProvider = currentUnitOfWorkProvider;
_defaultOptions = defaultOptions;
}
示例15: DynamicAuthorizationManager
/// <summary>
/// Constructor.
/// </summary>
public DynamicAuthorizationManager(
IIocManager iocManager,
IPermissionDefinitionContext permissionContext,
IAuthorizationConfiguration authorizationConfiguration
)
{
_iocManager = iocManager;
_permissionContext = permissionContext;
_authorizationConfiguration = authorizationConfiguration;
}