示例#1
0
        protected void SetAbort()
        {
            DataContextAttribute dca = ExtractNestedContextAttribute();

            if (dca == null)
            {
                return;
            }

            ContextManager.Instance.SetAbort(dca.ContextName);
        }
示例#2
0
        private DataContextAttribute ExtractNestedContextAttribute()
        {
            StackTrace stackTrace = new StackTrace();

            StackFrame[] stackFrames = stackTrace.GetFrames();
            foreach (StackFrame stackFrame in stackFrames)
            {
                MethodBase method = stackFrame.GetMethod();
                object[]   attrs  = method.GetCustomAttributes(typeof(DataContextAttribute), false);
                if (attrs.Length > 0)
                {
                    DataContextAttribute dca = attrs[0] as DataContextAttribute;
                    return(dca);
                }
            }
            return(null);
        }