本文整理汇总了C#中System.Type.IsConcrete方法的典型用法代码示例。如果您正苦于以下问题:C# Type.IsConcrete方法的具体用法?C# Type.IsConcrete怎么用?C# Type.IsConcrete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Type
的用法示例。
在下文中一共展示了Type.IsConcrete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public void Process(Type type, Registry registry)
{
// Only work on concrete types
if (!type.IsConcrete() || type.IsGenericType) return;
// Register against all the interfaces implemented
// by this concrete class
type.GetInterfaces().Each(@interface => { registry.For(@interface).Use(type); });
}
示例2: To
public IBindingScope To(Type concreteType)
{
Assert.IsNotNull(concreteType);
Assert.IsTrue(concreteType.IsConcrete());
Assert.IsTrue(concreteType.Is(ContractType));
return ToMethod(c => c.Container.Instantiator
.Instantiate(new InjectionContext { Container = c.Container, DeclaringType = concreteType }));
}
示例3: GetServiceRoutes
public IEnumerable<Route> GetServiceRoutes(Type serviceType)
{
if (!serviceType.IsConcrete())
throw new ArgumentException("Type " + serviceType + " must be a concrete type", "serviceType");
return MethodsToRoutes(
this.GetServiceMethodsFrom(serviceType)
.Where(x => !x.IsShadowed(serviceType))
.Select(x => x.IsVirtual? x.GetBaseDefinition(): x));
}
示例4: GetInterfaceType
void IAssemblyScannerConvention.Process(Type type, IUnityRegistry registry)
{
if (!type.IsConcrete() || !type.CanBeCreated())
return;
Type interfaceType = GetInterfaceType(type);
if (interfaceType != null)
registry.Register(interfaceType, type);
}
示例5: Process
public void Process(Type type, Registry registry)
{
if (!type.IsConcrete()) return;
var baseType = type.BaseType;
if (baseType != null && baseType.IsGenericType && baseType.GetGenericTypeDefinition() == m_mapType)
{
registry.AddType(baseType, type);
}
}
示例6: Process
public void Process(Type type, Registry registry)
{
// Only work on concrete types
if (!type.IsConcrete() || type.IsGenericType) return;
// Register against all the interfaces implemented
// by this concrete class
type.GetInterfaces()
.Where(@interface => @interface.Name == string.Format("I{0}", type.Name))
.ForEach(@interface => registry.For(@interface).Use(type).Singleton());
}
示例7: Process
public override void Process(Type type, Registry registry)
{
if (!type.IsConcrete() || !type.CanBeCreated()) return;
Type interfaceType = type.AllInterfaces().FirstOrDefault();
if (interfaceType != null)
{
registry.AddType(interfaceType, type);
ConfigureFamily(registry.For(interfaceType));
}
}
示例8: Process
public override void Process(Type type, Registry registry)
{
if (!type.IsConcrete()) return;
var pluginType = FindPluginType(type);
if (pluginType != null && type.HasConstructors())
{
registry.AddType(pluginType, type);
ConfigureFamily(registry.For(pluginType));
}
}
示例9: Process
public override void Process(Type type, Registry registry)
{
if (!type.IsConcrete() || !type.CanBeCreated()) return;
Type interfaceType = type.AllInterfaces().FirstOrDefault();
if (interfaceType != null)
{
Debug.WriteLine("Plugging {0} into {1}".ToFormat(type.Name, interfaceType.Name));
registry.AddType(interfaceType, type);
ConfigureFamily(registry.For(interfaceType));
}
}
示例10: Bind
public object Bind(Type type, IBindingContext context)
{
var entity = context.ValueAs(type, "Id");
if (entity != null) return entity;
if (type.IsConcrete())
{
return Activator.CreateInstance(type);
}
return null;
}
示例11: Process
public void Process(Type type, Registry registry)
{
if (!type.IsConcrete())
return;
if (!typeof(IHelpContext).IsAssignableFrom(type))
return;
var name = type.GetCustomAttributes(false).OfType<InstanceNameAttribute>().Select(x => x.Name).FirstOrDefault();
if (string.IsNullOrEmpty(name))
return;
registry.For(typeof(IHelpContext)).Use(type).Named(name.ToLowerInvariant());
}
示例12: Process
public override void Process(Type type, Registry registry)
{
if (!type.IsConcrete())
return;
var pluginType = FindPluginType(type);
if (pluginType == null || !Constructor.HasConstructors(type))
return;
registry.For(pluginType)
.EnrichWith(z => DynamicProxy.CreateInterfaceProxyWithTarget(pluginType, z, _aspects))
.Use(type);
}
示例13: Process
public void Process(Type type, Registry registry)
{
// Only work on concrete types
if (!type.IsConcrete() || type.IsGenericType) return;
// Add against all the interfaces implemented
// by this concrete class
type.GetInterfaces()
.Where(@interface => @interface.Name == $"I{type.Name}" )
.ForEach(@interface => registry.For(@interface).Use(type).Singleton());
if (type.Name.EndsWith("Job"))
registry.For(type).Singleton();
}
示例14: ConverterFor
public Func<string, object> ConverterFor(Type type)
{
if (!type.IsConcrete()) {
return null;
}
var constructor = type.GetConstructor (new [] { typeof(string) });
if (constructor == null) {
return null;
}
var param = Expression.Parameter (typeof(string), "arg");
var body = Expression.New (constructor, param);
return Expression.Lambda<Func<string, object>> (body, param).Compile();
}
示例15: Process
public override void Process(Type type, Registry registry)
{
var interfaceTypes = type.FindInterfacesThatClose(_openType);
if (!interfaceTypes.Any()) return;
if (type.IsConcrete())
{
_concretions.Add(type);
}
foreach (var interfaceType in interfaceTypes)
{
_interfaces.Add(interfaceType);
}
}