示例#1
0
        private Parameter[] GetParameters(IInvocation invocation)
        {
            var copier       = Mimic.GetCopier();
            var output       = new List <Parameter>();
            var methodParams = invocation.Method.GetParameters();

            foreach (var param in methodParams)
            {
                var type = invocation.Arguments[param.Position] != null
                    ? invocation.Arguments[param.Position].GetType()
                    : param.ParameterType;

                output.Add(
                    new Parameter()
                {
                    Name = param.Name,
                    ParameterActualType   = type.AssemblyQualifiedName,
                    ParameterExpectedType = param.ParameterType.AssemblyQualifiedName,
                    Value = copier.Copy(invocation.Arguments[param.Position])
                });
            }
            return(output.ToArray());
        }
示例#2
0
        private LoggedCall ConvertToLoggedCall(IInvocation invocation)
        {
            Type t;

            if (invocation.ReturnValue != null)
            {
                t = invocation.ReturnValue.GetType();
            }
            else
            {
                t = invocation.Method.ReturnType;
            }
            var copier = Mimic.GetCopier();

            return(new LoggedCall()
            {
                MethodName = invocation.Method.Name,
                MethodDeclaringTypeName = invocation.Method.DeclaringType.AssemblyQualifiedName,
                ReturnValue = copier.Copy(invocation.ReturnValue),
                ReturnType = t.AssemblyQualifiedName,
                Parameters = GetParameters(invocation)
            });
        }