diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index 3903ded..69bb4a7 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -186,7 +186,7 @@ static TypeExtensions() /// MethodInfo or null if no matches found /// /// - public static MethodInfo GetGenericMethod(this Type sourceType, System.Reflection.BindingFlags bindingFlags, string methodName, Type[] genericTypes, Type[] parameterTypes) + public static MethodInfo GetGenericMethod(this Type sourceType, BindingFlags bindingFlags, string methodName, Type[] genericTypes, Type[] parameterTypes) { MethodInfo method; var cacheKey = new GenericMethodCacheKey(sourceType, methodName, genericTypes, parameterTypes); @@ -589,7 +589,7 @@ public RegisterOptions(TinyIoCContainer container, TypeRegistration registration /// Make registration a singleton (single instance) if possible /// /// RegisterOptions - /// + /// public RegisterOptions AsSingleton() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -604,7 +604,7 @@ public RegisterOptions AsSingleton() /// Make registration multi-instance if possible /// /// RegisterOptions - /// + /// public RegisterOptions AsMultiInstance() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -619,7 +619,7 @@ public RegisterOptions AsMultiInstance() /// Make registration hold a weak reference if possible /// /// RegisterOptions - /// + /// public RegisterOptions WithWeakReference() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -634,7 +634,7 @@ public RegisterOptions WithWeakReference() /// Make registration hold a strong reference if possible /// /// RegisterOptions - /// + /// public RegisterOptions WithStrongReference() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -718,7 +718,7 @@ public MultiRegisterOptions(IEnumerable registerOptions) /// Make registration a singleton (single instance) if possible /// /// RegisterOptions - /// + /// public MultiRegisterOptions AsSingleton() { _RegisterOptions = ExecuteOnAllRegisterOptions(ro => ro.AsSingleton()); @@ -729,7 +729,7 @@ public MultiRegisterOptions AsSingleton() /// Make registration multi-instance if possible /// /// MultiRegisterOptions - /// + /// public MultiRegisterOptions AsMultiInstance() { _RegisterOptions = ExecuteOnAllRegisterOptions(ro => ro.AsMultiInstance()); @@ -990,7 +990,7 @@ public RegisterOptions Register(Type registerType, Func /// Creates/replaces a container class registration with default options. /// - /// Type to register + /// Type to register /// RegisterOptions for fluent API public RegisterOptions Register() where RegisterType : class @@ -1001,7 +1001,7 @@ public RegisterOptions Register() /// /// Creates/replaces a named container class registration with default options. /// - /// Type to register + /// Type to register /// Name of registration /// RegisterOptions for fluent API public RegisterOptions Register(string name) @@ -1150,7 +1150,7 @@ public MultiRegisterOptions RegisterMultiple(IEnumerable imp public MultiRegisterOptions RegisterMultiple(Type registrationType, IEnumerable implementationTypes) { if (implementationTypes == null) - throw new ArgumentNullException("types", "types is null."); + throw new ArgumentNullException("implementationTypes", "implementationTypes is null."); foreach (var type in implementationTypes) if (!registrationType.IsAssignableFrom(type)) @@ -1421,7 +1421,6 @@ public ResolveType Resolve(string name, NamedParameterOverloads par /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Bool indicating whether the type can be resolved public bool CanResolve(Type resolveType) { @@ -1434,6 +1433,7 @@ public bool CanResolve(Type resolveType) /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve + /// Name of registration /// Bool indicating whether the type can be resolved private bool CanResolve(Type resolveType, string name) { @@ -1446,7 +1446,6 @@ private bool CanResolve(Type resolveType, string name) /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Resolution options /// Bool indicating whether the type can be resolved public bool CanResolve(Type resolveType, ResolveOptions options) @@ -1542,7 +1541,6 @@ public bool CanResolve(Type resolveType, string name, NamedParameterOverloads pa /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Bool indicating whether the type can be resolved public bool CanResolve() where ResolveType : class @@ -1569,7 +1567,6 @@ public bool CanResolve(string name) /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Resolution options /// Bool indicating whether the type can be resolved public bool CanResolve(ResolveOptions options) @@ -1668,7 +1665,7 @@ public bool CanResolve(string name, NamedParameterOverloads paramet /// /// Attemps to resolve a type using the default options /// - /// Type to resolve + /// Type to resolve /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise public bool TryResolve(Type resolveType, out object resolvedType) @@ -1688,7 +1685,7 @@ public bool TryResolve(Type resolveType, out object resolvedType) /// /// Attemps to resolve a type using the given options /// - /// Type to resolve + /// Type to resolve /// Resolution options /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise @@ -1709,7 +1706,7 @@ public bool TryResolve(Type resolveType, ResolveOptions options, out object reso /// /// Attemps to resolve a type using the default options and given name /// - /// Type to resolve + /// Type to resolve /// Name of registration /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise @@ -1730,7 +1727,7 @@ public bool TryResolve(Type resolveType, string name, out object resolvedType) /// /// Attemps to resolve a type using the given options and name /// - /// Type to resolve + /// Type to resolve /// Name of registration /// Resolution options /// Resolved type or default if resolve fails @@ -1752,7 +1749,7 @@ public bool TryResolve(Type resolveType, string name, ResolveOptions options, ou /// /// Attemps to resolve a type using the default options and supplied constructor parameters /// - /// Type to resolve + /// Type to resolve /// User specified constructor parameters /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise @@ -1773,7 +1770,7 @@ public bool TryResolve(Type resolveType, NamedParameterOverloads parameters, out /// /// Attemps to resolve a type using the default options and supplied name and constructor parameters /// - /// Type to resolve + /// Type to resolve /// Name of registration /// User specified constructor parameters /// Resolved type or default if resolve fails @@ -1795,8 +1792,7 @@ public bool TryResolve(Type resolveType, string name, NamedParameterOverloads pa /// /// Attemps to resolve a type using the supplied options and constructor parameters /// - /// Type to resolve - /// Name of registration + /// Type to resolve /// User specified constructor parameters /// Resolution options /// Resolved type or default if resolve fails @@ -1818,7 +1814,7 @@ public bool TryResolve(Type resolveType, NamedParameterOverloads parameters, Res /// /// Attemps to resolve a type using the supplied name, options and constructor parameters /// - /// Type to resolve + /// Type to resolve /// Name of registration /// User specified constructor parameters /// Resolution options @@ -1975,7 +1971,6 @@ public bool TryResolve(string name, NamedParameterOverloads paramet /// Attemps to resolve a type using the supplied options and constructor parameters /// /// Type to resolve - /// Name of registration /// User specified constructor parameters /// Resolution options /// Resolved type or default if resolve fails @@ -2022,7 +2017,7 @@ public bool TryResolve(string name, NamedParameterOverloads paramet /// /// Returns all registrations of a type /// - /// Type to resolveAll + /// Type to resolveAll /// Whether to include un-named (default) registrations /// IEnumerable public IEnumerable ResolveAll(Type resolveType, bool includeUnnamed) @@ -2033,7 +2028,7 @@ public IEnumerable ResolveAll(Type resolveType, bool includeUnnamed) /// /// Returns all registrations of a type, both named and unnamed /// - /// Type to resolveAll + /// Type to resolveAll /// IEnumerable public IEnumerable ResolveAll(Type resolveType) { @@ -2056,7 +2051,6 @@ public IEnumerable ResolveAll(bool includeUnnamed) /// Returns all registrations of a type, both named and unnamed /// /// Type to resolveAll - /// Whether to include un-named (default) registrations /// IEnumerable public IEnumerable ResolveAll() where ResolveType : class @@ -2703,7 +2697,7 @@ public static TinyIoCContainer Current #region Type Registrations public sealed class TypeRegistration { - private int _hashCode; + private readonly int _hashCode; public Type Type { get; private set; } public string Name { get; private set; } @@ -2901,11 +2895,6 @@ private RegisterOptions AddUpdateRegistration(TypeRegistration typeRegistration, return new RegisterOptions(this, typeRegistration); } - private void RemoveRegistration(TypeRegistration typeRegistration) - { - _RegisteredTypes.Remove(typeRegistration); - } - private ObjectFactoryBase GetDefaultObjectFactory(Type registerType, Type registerImplementation) { if (registerType.IsInterface || registerType.IsAbstract) @@ -3237,11 +3226,6 @@ private IEnumerable GetTypeConstructors(Type type) return type.GetConstructors().OrderByDescending(ctor => ctor.GetParameters().Count()); } - private object ConstructType(Type requestedType, Type implementationType, ResolveOptions options) - { - return ConstructType(requestedType, implementationType, null, NamedParameterOverloads.Default, options); - } - private object ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, ResolveOptions options) { return ConstructType(requestedType, implementationType, constructor, NamedParameterOverloads.Default, options);