/// <summary>
        /// returns a stack frame item from a stack frame. This 
        /// </summary>
        /// <param name="frame"></param>
        /// <returns></returns>
        public StackFrameItem(StackFrame frame)
        {
            // set default values
            m_lineNumber = NA;
            m_fileName = NA;
            m_method = new MethodItem();
            m_className = NA;

			try
			{
				// get frame values
				m_lineNumber = frame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
				m_fileName = frame.GetFileName();
				// get method values
				MethodBase method = frame.GetMethod();
				if (method != null)
				{
					if(method.DeclaringType != null)
						m_className = method.DeclaringType.FullName;
					m_method = new MethodItem(method);
				}
			}
			catch (Exception ex)
			{
				LogLog.Error(declaringType, "An exception ocurred while retreiving stack frame information.", ex);
			}

            // set full info
            m_fullInfo = m_className + '.' + m_method.Name + '(' + m_fileName + ':' + m_lineNumber + ')';
        }
        internal override string GetMethodInformation(MethodItem method)
        {
            string returnValue="";

            try
            {
                string param = "";
                string[] names = method.Parameters;
                StringBuilder sb = new StringBuilder();
                if (names != null && names.GetUpperBound(0) > 0)
                {
                    for (int i = 0; i <= names.GetUpperBound(0); i++)
                    {
                        sb.AppendFormat("{0}, ", names[i]);
                    }
                }

                if (sb.Length > 0)
                {
                    sb.Remove(sb.Length - 2, 2);
                    param = sb.ToString();
                }

                returnValue=base.GetMethodInformation(method) + "(" + param + ")";
            }
            catch (Exception ex)
            {
                LogLog.Error(declaringType, "An exception ocurred while retreiving method information.", ex);
            }

            return returnValue;
        }
Beispiel #3
0
 public StackFrameItem(StackFrame frame)
 {
     try
     {
         this.m_lineNumber = frame.GetFileLineNumber().ToString(NumberFormatInfo.InvariantInfo);
         this.m_fileName   = frame.GetFileName();
         MethodBase method = frame.GetMethod();
         if (method != null)
         {
             if (method.DeclaringType != null)
             {
                 this.m_className = method.DeclaringType.FullName;
             }
             this.m_method = new MethodItem(method);
         }
     }
     catch (Exception exception)
     {
         LogLog.Error(declaringType, "An exception ocurred while retreiving stack frame information.", exception);
     }
     object[] objArray1 = new object[] { this.m_className, '.', this.m_method.Name, '(', this.m_fileName, ':', this.m_lineNumber, ')' };
     this.m_fullInfo = string.Concat(objArray1);
 }
         /// <summary>
 /// Returns the Name of the method
 /// </summary>
 /// <param name="method"></param>
 /// <remarks>This method was created, so this class could be used as a base class for StackTraceDetailPatternConverter</remarks>
 /// <returns>string</returns>
 internal virtual string GetMethodInformation(MethodItem method)
 {
     return method.Name;
 }