本文整理汇总了C#中IObjectFactory.RegisterType方法的典型用法代码示例。如果您正苦于以下问题:C# IObjectFactory.RegisterType方法的具体用法?C# IObjectFactory.RegisterType怎么用?C# IObjectFactory.RegisterType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObjectFactory
的用法示例。
在下文中一共展示了IObjectFactory.RegisterType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public void Initialize(IObjectFactory factory)
{
foreach (var type in AssemblyScanner.GetAllTypes())
{
var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
if (attr != null && attr.Length == 1)
{
var st = attr[0].Scope;
factory.RegisterType(type, type, st);
foreach (var i in type.GetInterfaces())
factory.RegisterType(type, i, st);
}
}
}
示例2: Initialize
public void Initialize(IObjectFactory factory)
{
foreach (var type in AssemblyScanner.GetAllTypes())
{
var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
if (attr != null && attr.Length == 1)
factory.RegisterType(type, attr[0].Scope, new[] { type }.Union(type.GetInterfaces()).ToArray());
}
}
示例3: Initialize
public void Initialize(IObjectFactory factory)
{
foreach (var type in AssemblyScanner.GetAllTypes().Where(it => it.IsPublic || it.IsNestedPublic))
{
var interfaces =
(from i in type.GetInterfaces()
where i.IsGenericType
&& i.GetGenericTypeDefinition() == typeof(IDomainEventHandler<>)
select i).ToList();
if (interfaces.Count > 0)
{
var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
if (attr == null || attr.Length == 0)
{
factory.RegisterType(type);
foreach (var i in interfaces)
factory.RegisterType(type, i, InstanceScope.Transient);
}
}
}
}
示例4: Initialize
public void Initialize(IObjectFactory factory)
{
foreach (var type in AssemblyScanner.GetAllTypes().Where(it => it.IsPublic || it.IsNestedPublic))
{
if (type.GetInterfaces().Any(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IServerService<,>)))
{
var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
if (attr == null || attr.Length == 0)
factory.RegisterType(type);
}
}
}
示例5: Initialize
public void Initialize(IObjectFactory factory)
{
var plugins = new Dictionary<Type, InstanceScope>();
foreach (var type in AssemblyScanner.GetAllTypes())
{
var attr = type.GetCustomAttributes(typeof(PluginAttribute), false) as PluginAttribute[];
if (attr != null && attr.Length == 1)
plugins.Add(type, attr[0].Scope);
}
foreach (var type in AssemblyScanner.GetAllTypes())
{
if (type.IsClass && !type.IsAbstract)
{
foreach (var i in type.GetInterfaces())
if (plugins.ContainsKey(i))
factory.RegisterType(type, i, plugins[i]);
}
}
}
示例6: Initialize
public void Initialize(IObjectFactory factory)
{
foreach (var type in AssemblyScanner.GetAllTypes())
{
if (type.IsAbstract || !type.IsClass)
continue;
var interfaces =
(from i in type.GetInterfaces()
where i.IsGenericType
&& i.GetGenericTypeDefinition() == typeof(IDomainEventHandler<>)
select i).ToList();
if (interfaces.Count > 0)
{
var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
if (attr == null || attr.Length == 0)
factory.RegisterType(type, InstanceScope.Transient, new[] { type }.Union(interfaces).ToArray());
}
}
}