Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }