Example #1
0
        public object Invoke(IMethodInvocation invocation)
        {
            Console.WriteLine("Method in ConsoleLoggingAroundAdvice");

            object obj = invocation.Proceed();

            Console.WriteLine("invocation type is :{0}", invocation.GetType().ToString());
            Console.WriteLine("Method name is {0}", invocation.Method.ToString());
            return(obj);
        }
        public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
        {
            _logger.Debug("Interecptor: {0}, Call begin {1}", GetType(), input.GetType().ToString(), input.MethodBase.ToString());
            var result = getNext()(input, getNext);

            if (result.Exception != null)
            {
                _logger.Error(result.Exception);
            }
            else
            {
                _logger.Debug("Interecptor: {0}, Call end {1} [Return={2}]", GetType(), input.MethodBase.ToString(), result.ReturnValue);
            }
            return(result);
        }
        /// <summary>
        /// Build the cache key using the type name, method name and parameter argument values.
        /// </summary>
        /// <param name="input">Aspect arguments.</param>
        /// <returns>Cache key.</returns>
        private string BuildCacheKey(IMethodInvocation input)
        {
            const string divider = "_";

            var typeName = GetTypeName(input.GetType());

            var cacheKey = new StringBuilder();

            cacheKey.Append(typeName);
            cacheKey.Append(divider);
            cacheKey.Append(input.MethodBase.Name);

            foreach (var argument in input.Arguments)
            {
                cacheKey.Append(argument == null ? divider : argument.ToString());
            }

            return(cacheKey.ToString());
        }