예제 #1
0
 public H跟踪(string 信息, Dictionary <string, object> 参数, string __方法, string __文件, int __行号)
 {
     _开始时间 = Environment.TickCount;
     _信息   = 信息;
     _标识   = __标识序列号++;
     H调试.记录提示(string.Format("[[{0} {1}", _标识, 信息), 参数, __方法, __文件, __行号);
 }
예제 #2
0
        public void Dispose()
        {
            int 耗时 = Environment.TickCount - _开始时间;

            if (_上下文.Count > 0)
            {
                刷新上下文();
            }
            H调试.记录提示(string.Format("]]{0} {1}[耗时: {2:f3}]", _标识 * -1, _信息, 耗时 / 1000.0));
        }
예제 #3
0
        public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
        {
            if (input.MethodBase.IsDefined(typeof(NoLogAttribute), false) || input.MethodBase.Name.Contains("get_"))
            {
                return(getNext()(input, getNext));
            }
            var __title   = new StringBuilder();
            var __content = new StringBuilder();

            if (input.Arguments.Count > 0)
            {
                __content.AppendFormat("[参数] {0}", input.MethodBase.IsDefined(typeof(NoLogArgumentsAttribute), false) ? "省略" : ArrayTojson(input.Arguments));
            }
            H调用顺序.Order++;
            __title.Append("".PadLeft(H调用顺序.Order * 2, ' '));
            __title.AppendFormat("[{0}]", H调用顺序.Order);
            __title.AppendFormat("[{0}].{1}", input.MethodBase.DeclaringType, input.MethodBase.Name);
            H调试.记录明细(__title.ToString(), __content.ToString(), null, null, 0);
            __content.Clear();

            IMethodReturn __结果 = getNext()(input, getNext);

            if (__结果.Exception != null)
            {
                //var __frame = new System.Diagnostics.StackTrace(ex, 0, true).GetFrame(0);
                __content.AppendFormat("[Error] {0}: {1}", __结果.Exception.GetType(), __结果.Exception.Message);
                H调试.记录提示(__title.ToString(), __content.ToString(), null, null, 0);
            }
            else
            {
                bool __存在执行结果 = false;
                if (__结果.ReturnValue != null && !input.MethodBase.IsDefined(typeof(NoLogReturnValueAttribute), false))
                {
                    __content.AppendFormat("[返回值] {0}", Tojson(__结果.ReturnValue));
                    __存在执行结果 = true;
                }
                if (__结果.Outputs != null && __结果.Outputs.Count > 0 && !input.MethodBase.IsDefined(typeof(NoLogReturnValueAttribute), false))
                {
                    __content.AppendFormat("[输出参数] {0}", Tojson(__结果.Outputs));
                    __存在执行结果 = true;
                }
                if (__存在执行结果)
                {
                    H调试.记录明细(__title.ToString(), __content.ToString(), null, null, 0);
                }
            }
            H调用顺序.Order--;
            return(__结果);
        }