private string GetMethodKey(InvocationContext invocationContext) { var key = string.Format("{0}.{1}", invocationContext.GetInvocation().TargetType.FullName, invocationContext.GetInvocation().Method.Name); var arguments = invocationContext.GetInvocation().Arguments; key += "(" + string.Join(",", arguments) + ")"; return(key); }
private List <LogArgument> GetArguments(InvocationContext invocationContext) { var arguments = new List <LogArgument>(); int _argumentsLength = invocationContext.GetInvocation().Arguments.Length; if (_argumentsLength > 0) { for (int i = 0; i < _argumentsLength; i++) { arguments.Add(new LogArgument { Name = invocationContext.GetParameterValue(i).ToString() }); } } return(arguments); }
public void BeforeInvoke(InvocationContext invocationContext) { this._logAttribute = invocationContext.GetAttributeFromMethod <LogAttribute>(); if (typeof(ILoggerService).IsAssignableFrom(_logAttribute._loggerServiceType) == false) { throw new Exception("Wrong log manager"); } logManager = (ILoggerService)ActivatorUtilities.CreateInstance(_serviceProvider, _logAttribute._loggerServiceType); LogDetail _log = new LogDetail() { DateTime = DateTime.Now, FullName = invocationContext.GetInvocation().TargetType.FullName, MethodName = invocationContext.GetExecutingMethodInfo().Name, Type = _logAttribute._logType.ToString() // Arguments = GetArguments(invocationContext) }; logManager.Logging(_log); }