public static Type GetTargetType(MethodInput input)
        {
            Type targetType;

            if (input.Method.DeclaringType.IsAbstract)
            {
                targetType = input.TargetType;
            }
            else
            {
                targetType = input.Method.DeclaringType;
            }

            return(targetType);
        }
        public static object[] ToArgs(this ILogValueMapper logValueMapper, MethodInput input)
        {
            if (input == null)
            {
                throw new ArgumentNullException();
            }

            var args = input.Method.GetParameters()
                       .Select(i => new
            {
                i.Name,
                Value = logValueMapper.Map(input.Arguments[i.Position])
            });

            return(args.ToArray());
        }
Пример #3
0
        public (ILogMessage logMessage, object correlationState) CreateInputMethodLogMessage(MethodInput methodInput)
        {
            var sw = new Stopwatch();

            var(logMessage, correlationState) = Target.CreateInputMethodLogMessage(methodInput);

            sw.Start();

            return(logMessage, correlationState : new CorrelationState {
                Stopwatch = sw, InnerCorrelationState = correlationState
            });
        }
Пример #4
0
        public (ILogMessage logMessage, object correlationState) CreateInputMethodLogMessage(MethodInput methodInput)
        {
            var targetType = GetTargetType(methodInput);

            var logMessage = new LogMessage(_logMessageSettings.InputLogMessageTemplate);

            var className = ToShortName(targetType);

            logMessage.AddMessageProperty("ClassName", className);

            var methodName = methodInput.Method.Name;

            logMessage.AddMessageProperty("MethodName", methodName);

            var inputArgs = JsonConvert.SerializeObject(_logValueMapper.ToArgs(methodInput), JsonSettings);

            logMessage.AddMessageProperty("InputArgs", inputArgs);

            return(logMessage, correlationState : new CorrelationState {
                Input = methodInput, ClassName = className, MethodName = methodName
            });
        }
        public (ILogMessage logMessage, object correlationState) CreateInputMethodLogMessage(MethodInput methodInput)
        {
            var(logMessage, correlationState) = Target.CreateInputMethodLogMessage(methodInput);

            var targetHashCode = methodInput.Target.GetHashCode();

            logMessage.AddMessageProperty("HashCode", targetHashCode);

            return(logMessage, correlationState : new CorrelationState {
                TargetHashCode = targetHashCode, InnerCorrelationState = correlationState
            });
        }