|
|
|
@ -72,29 +72,15 @@ namespace LightweightIocContainer |
|
|
|
/// <param name="arguments">The constructor arguments</param> |
|
|
|
/// <param name="arguments">The constructor arguments</param> |
|
|
|
/// <returns>An instance of the given type</returns> |
|
|
|
/// <returns>An instance of the given type</returns> |
|
|
|
/// <exception cref="InternalResolveException">Could not find function <see cref="ResolveInternal{T}"/></exception> |
|
|
|
/// <exception cref="InternalResolveException">Could not find function <see cref="ResolveInternal{T}"/></exception> |
|
|
|
public object Resolve(object type, object arguments) //somehow the order of the arguments is different in the application compared to the unit test |
|
|
|
public object Resolve(Type type, object[] arguments) //somehow the order of the arguments is different in the application compared to the unit test |
|
|
|
{ |
|
|
|
{ |
|
|
|
Type realType; |
|
|
|
|
|
|
|
object[] realArguments; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == null || type.GetType().IsArray) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
realType = (Type) arguments; |
|
|
|
|
|
|
|
realArguments = (object[]) type; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
realType = (Type) type; |
|
|
|
|
|
|
|
realArguments = (object[]) arguments; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var resolveMethod = typeof(InjectorContainer).GetMethod(nameof(ResolveInternal), BindingFlags.NonPublic | BindingFlags.Instance); |
|
|
|
var resolveMethod = typeof(InjectorContainer).GetMethod(nameof(ResolveInternal), BindingFlags.NonPublic | BindingFlags.Instance); |
|
|
|
var genericResolveMethod = resolveMethod?.MakeGenericMethod(realType); |
|
|
|
var genericResolveMethod = resolveMethod?.MakeGenericMethod(type); |
|
|
|
|
|
|
|
|
|
|
|
if (genericResolveMethod == null) |
|
|
|
if (genericResolveMethod == null) |
|
|
|
throw new InternalResolveException($"Could not find function {nameof(ResolveInternal)}"); |
|
|
|
throw new InternalResolveException($"Could not find function {nameof(ResolveInternal)}"); |
|
|
|
|
|
|
|
|
|
|
|
return genericResolveMethod.Invoke(this, new object[] {realArguments}); |
|
|
|
return genericResolveMethod.Invoke(this, new object[] {arguments}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
|