private static ResolvedConstructor ResolveConstructorArguments(ConstructorInfo constructor, IDummyValueCreationSession session) { Logger.Debug("Beginning to resolve constructor with {0} arguments.", constructor.GetParameters().Length); var resolvedArguments = new List<ResolvedArgument>(); foreach (var argument in constructor.GetParameters()) { object result = null; var resolvedArgument = new ResolvedArgument { WasResolved = session.TryResolveDummyValue(argument.ParameterType, out result), ResolvedValue = result, ArgumentType = argument.ParameterType }; Logger.Debug("Was able to resolve {0}: {1}.", argument.ParameterType, resolvedArgument.WasResolved); resolvedArguments.Add(resolvedArgument); } return new ResolvedConstructor { Arguments = resolvedArguments.ToArray() }; }
private static ResolvedConstructor ResolveConstructorArguments(ConstructorInfo constructor, IDummyValueCreationSession session) { logger.Debug("Beginning to resolve constructor with {0} arguments.", constructor.GetParameters().Length); var resolvedArguments = new List <ResolvedArgument>(); foreach (var argument in constructor.GetParameters()) { object result = null; var resolvedArgument = new ResolvedArgument { WasResolved = session.TryResolveDummyValue(argument.ParameterType, out result), ResolvedValue = result, ArgumentType = argument.ParameterType }; logger.Debug("Was able to resolve {0}: {1}.", argument.ParameterType, resolvedArgument.WasResolved); resolvedArguments.Add(resolvedArgument); } return(new ResolvedConstructor { Arguments = resolvedArguments.ToArray() }); }
private static IEnumerable <ResolvedArgument> ResolveArguments( IEnumerable <Type> parameterTypes, IDummyValueResolver resolver, LoopDetectingResolutionContext resolutionContext) { var resolvedArguments = new List <ResolvedArgument>(); foreach (var parameterType in parameterTypes) { var resolvedArgument = new ResolvedArgument(parameterType); try { var creationResult = resolver.TryResolveDummyValue(parameterType, resolutionContext); resolvedArgument.WasResolved = creationResult.WasSuccessful; if (creationResult.WasSuccessful) { resolvedArgument.ResolvedValue = creationResult.Result; } } catch { resolvedArgument.WasResolved = false; } resolvedArguments.Add(resolvedArgument); } return(resolvedArguments); }
private static IEnumerable<ResolvedArgument> ResolveArguments( IEnumerable<Type> parameterTypes, DummyCreationSession session, IDummyValueResolver resolver) { var resolvedArguments = new List<ResolvedArgument>(); foreach (var parameterType in parameterTypes) { var resolvedArgument = new ResolvedArgument { ArgumentType = parameterType }; try { var creationResult = resolver.TryResolveDummyValue(session, parameterType); resolvedArgument.WasResolved = creationResult.WasSuccessful; if (creationResult.WasSuccessful) { resolvedArgument.ResolvedValue = creationResult.Result; } } catch { resolvedArgument.WasResolved = false; } resolvedArguments.Add(resolvedArgument); } return resolvedArguments; }
private static ResolvedConstructor ResolveConstructorArguments(ConstructorInfo constructor, DummyCreationSession session, IDummyValueResolver resolver) { var resolvedArguments = new List <ResolvedArgument>(); foreach (var argument in constructor.GetParameters()) { bool wasResolved; object result = null; try { wasResolved = resolver.TryResolveDummyValue(session, argument.ParameterType, out result); } catch { wasResolved = false; } var resolvedArgument = new ResolvedArgument { WasResolved = wasResolved, ResolvedValue = result, ArgumentType = argument.ParameterType }; resolvedArguments.Add(resolvedArgument); } return(new ResolvedConstructor { Arguments = resolvedArguments.ToArray() }); }
private static ResolvedConstructor ResolveConstructorArguments(Type[] parameterTypes, DummyCreationSession session, IDummyValueResolver resolver) { if (parameterTypes == null) { return(new ResolvedConstructor()); } var resolvedArguments = new List <ResolvedArgument>(); foreach (var parameterType in parameterTypes) { bool wasResolved; object result = null; try { wasResolved = resolver.TryResolveDummyValue(session, parameterType, out result); } catch { wasResolved = false; } var resolvedArgument = new ResolvedArgument { WasResolved = wasResolved, ResolvedValue = result, ArgumentType = parameterType }; resolvedArguments.Add(resolvedArgument); } return(new ResolvedConstructor { Arguments = resolvedArguments.ToArray() }); }
private static ResolvedConstructor ResolveConstructorArguments(ConstructorInfo constructor, IDummyValueCreationSession session) { var resolvedArguments = new List<ResolvedArgument>(); foreach (var argument in constructor.GetParameters()) { object result; var resolvedArgument = new ResolvedArgument { WasResolved = session.TryResolveDummyValue(argument.ParameterType, out result), ResolvedValue = result, ArgumentType = argument.ParameterType }; resolvedArguments.Add(resolvedArgument); } return new ResolvedConstructor { Arguments = resolvedArguments.ToArray() }; }
private static ResolvedConstructor ResolveConstructorArguments(ConstructorInfo constructor, IDummyValueCreationSession session) { var resolvedArguments = new List <ResolvedArgument>(); foreach (var argument in constructor.GetParameters()) { object result; var resolvedArgument = new ResolvedArgument { WasResolved = session.TryResolveDummyValue(argument.ParameterType, out result), ResolvedValue = result, ArgumentType = argument.ParameterType }; resolvedArguments.Add(resolvedArgument); } return(new ResolvedConstructor { Arguments = resolvedArguments.ToArray() }); }