コード例 #1
1
        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()
                       };
        }
コード例 #2
0
        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()
            });
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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()
            });
        }
コード例 #6
0
        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()
            });
        }
コード例 #7
0
        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()
                       };
        }
コード例 #8
0
        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()
            });
        }