public JsonLocationInfo(LocationInfo locationInfo)
 {
     this.ClassName = locationInfo.ClassName;
     this.FileName = locationInfo.FileName;
     this.FullInfo = locationInfo.FullInfo;
     this.LineNumber = locationInfo.LineNumber;
     this.MethodName = locationInfo.MethodName;
     this.StackFrames = locationInfo.StackFrames;
 }
 public JsonLocationInfo(LocationInfo locationInfo)
 {
     ClassName = locationInfo.ClassName;
     FileName = locationInfo.FileName;
     FullInfo = locationInfo.FullInfo;
     LineNumber = locationInfo.LineNumber;
     MethodName = locationInfo.MethodName;
     StackFrames = locationInfo.StackFrames;
 }
        protected void ParseLocationInfo(LocationInfo locationInformation, Dictionary<string, object> resultDictionary)
        {
            if (FixedFields.ContainsFlag(FixFlags.LocationInfo) && locationInformation != null)
            {
                var locationInfo = new Dictionary<string, object>();
                resultDictionary["LocationInformation"] = locationInfo;

                locationInfo["ClassName"] = locationInformation.ClassName;
                locationInfo["FileName"] = locationInformation.FileName;
                locationInfo["LineNumber"] = locationInformation.LineNumber;
                locationInfo["FullInfo"] = locationInformation.FullInfo;
                locationInfo["MethodName"] = locationInformation.MethodName;
            }
        }
Exemple #4
0
        public LocationInfo(log4net.Core.LocationInfo locationInfo)
        {
            this.className = locationInfo.ClassName;
            this.fileName  = locationInfo.FileName;
            if (!int.TryParse(locationInfo.LineNumber, out this.lineNumber))
            {
                this.lineNumber = 0;
            }
            this.methodName = locationInfo.MethodName;

            if (string.IsNullOrEmpty(this.fileName))
            {
                this.fullInfo = this.className + '.' + this.methodName + "()";
            }
            else
            {
                this.fullInfo = this.className + '.' + this.methodName + '(' + this.fileName + ':' + this.lineNumber + ')';
            }

            var frames = locationInfo.StackFrames;

            if (frames == null)
            {
                return;
            }

            List <StackFrameItem> list = new List <StackFrameItem>();

            foreach (var frame in frames)
            {
                try
                {
                    if (frame == null)
                    {
                        continue;
                    }

                    var            method     = frame.Method;
                    string         methodName = method.Name;
                    string         className  = frame.ClassName;
                    StackFrameItem item       = new StackFrameItem(className, methodName, frame.FileName, int.Parse(frame.LineNumber));
                    list.Add(item);
                }
                catch (Exception) { }
            }

            this.stackFrames = list.ToArray();
        }
 private static EventLocation getLocation(string id, LocationInfo loc)
 {
     EventLocation eloc = new EventLocation();
     eloc.EventID = id;
     eloc.ClassName_ = loc.ClassName;
     // 220 is the current FileName_ size.
     eloc.FileName_ = loc.FileName != null && loc.FileName.Length > 220 ? "..." + loc.FileName.Substring(loc.FileName.Length - 220 - 3) : loc.FileName;
     eloc.MethodName_ = loc.MethodName;
     eloc.LineNumber = loc.LineNumber;
     if (loc.StackFrames != null && loc.StackFrames.Length > 0)
     {
         List<EventStackFrame> frames = new List<EventStackFrame>();
         int frmId = 1;
         foreach (var frm in loc.StackFrames)
         {
             if (_maxStackFramesUp >= 0 && frmId > _maxStackFramesUp)
                 break;
             else if (_userStackFramesOnly && string.IsNullOrEmpty(frm.FileName))
                 continue;
             EventStackFrame efrm = new EventStackFrame();
             efrm.EventID = id;
             efrm.ID = frmId++;
             efrm.ClassName_ = frm.ClassName;
             // 220 is the current FileName_ size.
             efrm.FileName_ = frm.FileName != null && frm.FileName.Length > 220 ? "..." + frm.FileName.Substring(frm.FileName.Length - 220 - 3) : frm.FileName;
             efrm.LineNumber = frm.LineNumber;
             string callinfo = frm.Method.Name + "(";
             foreach (var p in frm.Method.Parameters)
                 callinfo += p + ", ";
             callinfo = callinfo.TrimEnd(", ".ToCharArray()) + ")";
             efrm.MethodInfo = callinfo;
             frames.Add(efrm);
         }
         eloc.ChangedEventStackFrames = frames.ToArray();
     }
     return eloc;
 }
Exemple #6
0
 static LocationInfo()
 {
     _instance = new LocationInfo(null);
 }