C# Class QuizProjectMvc.Web.CommonConventions

Show file Open project: kidroca/project-quiz-mvc Class Usage Examples

Public Methods

Method Description
RegisterAllImplementationsOfInterface ( Type>.Action registerMethod, Type interfaceTypes, Assembly implementationAssemblies, Type excludeTypes, string excludeRegEx ) : void

Registers all of the types that implement the passed in interfaceTypes with the DI container so they can be resolved as an IEnumerable{T} of values (where T is the interface type). This overload is for DI containers that allow the use of multiple registration method calls, one for each implementation of the interface.

RegisterAllImplementationsOfInterfaceSingle ( Action registerMethod, Type interfaceTypes, Assembly implementationAssemblies, Type excludeTypes, string excludeRegEx ) : void

Registers all of the types that implement the passed in interfaceTypes with the DI container so they can be resolved as an IEnumerable{T} of values (where T is the interface type). This overload is for DI containers that require the use of a multiple registration method call for all implementations a given interface.

RegisterDefaultConventions ( Type>.Action registerMethod, Assembly interfaceAssemblies, Assembly implementationAssemblies, Type excludeTypes, string excludeRegEx ) : void

Registers all single types in a set of assemblies that meet the following criteria: 1) The name of the type matches the interface name (I[TypeName] = [TypeName]) or 2) The name of the type matches the interface name + the suffix "Adapter" (I[TypeName] = [TypeName]Adapter) 3) The class does not have a string parameter in the constructor 4) The class is not decorated with the [ExcludeFromAutoRegistrationAttribute]

Private Methods

Method Description
GetImplementationsOfInterface ( Assembly assembly, Type interfaceType ) : IEnumerable
GetInterfaces ( Assembly assembly ) : IEnumerable
IsAdapterType ( Type interfaceType, Type implementationType ) : bool
IsDefaultType ( Type interfaceType, Type implementationType ) : bool
IsExcludedType ( Type type ) : bool
IsExcludedType ( Type type, Type excludeTypes ) : bool
IsExcludedType ( Type type, Type excludeTypes, string excludeRegEx ) : bool
IsExcludedType ( Type type, string excludeRegEx ) : bool

Method Details

RegisterAllImplementationsOfInterface() public static method

Registers all of the types that implement the passed in interfaceTypes with the DI container so they can be resolved as an IEnumerable{T} of values (where T is the interface type). This overload is for DI containers that allow the use of multiple registration method calls, one for each implementation of the interface.
public static RegisterAllImplementationsOfInterface ( Type>.Action registerMethod, Type interfaceTypes, Assembly implementationAssemblies, Type excludeTypes, string excludeRegEx ) : void
registerMethod Type>.Action The method of the DI container used to register a single implementation, which will be /// called one time per implementation found to register each implementation of the type. Should be in the format /// (interfaceType, implementationType) => SomeMethod(interfaceType, implementationType) or similar.
interfaceTypes System.Type The interfaces to limit the registration to. If empty, no types will be registered.
implementationAssemblies System.Reflection.Assembly An array of assemblies to scan for the implementation types. /// This array should contain all of the assemblies where you have defined types that will be injected /// into MvcSiteMapProvider.
excludeTypes System.Type An array of used to manually exclude types if /// you intend to register them manually. Use this parameter if you want to inject your own implementation /// and therefore don't want the default type automatically registered.
excludeRegEx string A regular expression that can be used to exclude types based on the type /// name (excluding the namespace name). All types that match the regular expression will be excluded.
return void

RegisterAllImplementationsOfInterfaceSingle() public static method

Registers all of the types that implement the passed in interfaceTypes with the DI container so they can be resolved as an IEnumerable{T} of values (where T is the interface type). This overload is for DI containers that require the use of a multiple registration method call for all implementations a given interface.
public static RegisterAllImplementationsOfInterfaceSingle ( Action registerMethod, Type interfaceTypes, Assembly implementationAssemblies, Type excludeTypes, string excludeRegEx ) : void
registerMethod Action The method of the DI container used to register an array of implementations, which will be /// called only one time to register all of the implementations of the type. Should be in the format /// (interfaceType, implementationTypes) => SomeMethod(interfaceType, implementationTypes) or similar, where /// implementationTypes is a .
interfaceTypes System.Type The interfaces to limit the registration to. If empty, no types will be registered.
implementationAssemblies System.Reflection.Assembly An array of assemblies to scan for the implementation types. /// This array should contain all of the assemblies where you have defined types that will be injected /// into MvcSiteMapProvider.
excludeTypes System.Type An array of used to manually exclude types if /// you intend to register them manually. Use this parameter if you want to inject your own implementation /// and therefore don't want the default type automatically registered.
excludeRegEx string A regular expression that can be used to exclude types based on the type /// name (excluding the namespace name). All types that match the regular expression will be excluded.
return void

RegisterDefaultConventions() public static method

Registers all single types in a set of assemblies that meet the following criteria: 1) The name of the type matches the interface name (I[TypeName] = [TypeName]) or 2) The name of the type matches the interface name + the suffix "Adapter" (I[TypeName] = [TypeName]Adapter) 3) The class does not have a string parameter in the constructor 4) The class is not decorated with the [ExcludeFromAutoRegistrationAttribute]
public static RegisterDefaultConventions ( Type>.Action registerMethod, Assembly interfaceAssemblies, Assembly implementationAssemblies, Type excludeTypes, string excludeRegEx ) : void
registerMethod Type>.Action The method on the DI container used to register a type to an abstraction. /// Should be in the format (interfaceType, implementationType) => SomeMethod(interfaceType, implementationType) /// or similar.
interfaceAssemblies System.Reflection.Assembly An array of assemblies to scan for the interface types. These assemblies /// must be referenced within this project. Typically, you will just want to use the MvcSiteMapProvider /// assembly unless you decide to use throughout your project.
implementationAssemblies System.Reflection.Assembly An array of assemblies to scan for the implementation types. /// This array should contain all of the assemblies where you have defined types that will be injected /// into MvcSiteMapProvider.
excludeTypes System.Type An array of used to manually exclude types if /// you intend to register them manually. Use this parameter if you want to inject your own implementation /// and therefore don't want the default type automatically registered.
excludeRegEx string A regular expression that can be used to exclude types based on the type /// name (excluding the namespace name). All types that match the regular expression will be excluded.
return void