Classes
Entry point to fluent way to register, by convention, multiple concrete (non-abstract) classes (that include also delegate types). Use static methods on the class to fluently build registration.
using Castle.Core.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
namespace Castle.MicroKernel.Registration
{
public static class Classes
{
public static FromTypesDescriptor From(IEnumerable<Type> types)
{
return new FromTypesDescriptor(types, Filter);
}
public static FromTypesDescriptor From(params Type[] types)
{
return new FromTypesDescriptor(types, Filter);
}
public static FromAssemblyDescriptor FromAssembly(Assembly assembly)
{
if (assembly == (Assembly)null)
throw new ArgumentNullException("assembly");
return new FromAssemblyDescriptor(assembly, Filter);
}
public static FromAssemblyDescriptor FromAssemblyContaining(Type type)
{
if (type == (Type)null)
throw new ArgumentNullException("type");
return new FromAssemblyDescriptor(type.Assembly, Filter);
}
public static FromAssemblyDescriptor FromAssemblyContaining<T>()
{
return FromAssemblyContaining(typeof(T));
}
public static FromAssemblyDescriptor FromAssemblyInDirectory(AssemblyFilter filter)
{
if (filter == null)
throw new ArgumentNullException("filter");
IEnumerable<Assembly> assemblies = ReflectionUtil.GetAssemblies(filter);
return new FromAssemblyDescriptor(assemblies, Filter);
}
public static FromAssemblyDescriptor FromAssemblyNamed(string assemblyName)
{
Assembly assemblyNamed = ReflectionUtil.GetAssemblyNamed(assemblyName);
return FromAssembly(assemblyNamed);
}
public static FromAssemblyDescriptor FromThisAssembly()
{
return FromAssembly(Assembly.GetCallingAssembly());
}
[EditorBrowsable(EditorBrowsableState.Never)]
internal static bool Filter(Type type)
{
if (type.IsClass)
return !type.IsAbstract;
return false;
}
}
}