Exemplo n.º 1
0
 public NLogLoggingDeserializer()
     : base(new Dictionary <string, Action <LoggingData, XmlReader> >(StringComparer.OrdinalIgnoreCase)
 {
     { "logger", (l, r) => l.LoggerName = r.Value },
     { "domain", (l, r) => l.Domain = r.Value },
     { "username", (l, r) => l.UserName = r.Value },
     { "thread", (l, r) => l.ThreadName = r.Value },
     { "level", (l, r) => l.Level = r.Value },
     { "timestamp", (l, r) => l.TimeStamp = m_Log4jDateBase.AddMilliseconds(long.Parse(r.Value)).ToLocalTime() },
     { "message", (l, r) => l.Message = r.ReadElementContentAsString() },
     { "properties", ReadProperties },
     { "throwable", ReadException },
     { "locationInfo", XmlElementParser.CreateParser <LocationInfo>(new Dictionary <string, Action <LocationInfo, XmlReader> >(StringComparer.OrdinalIgnoreCase)
         {
             { "class", (l, r) => l.ClassName = r.Value },
             { "method", (l, r) => l.MethodName = r.Value },
             { "file", (l, r) => l.FileName = r.Value },
             { "line", (l, r) => l.LineNumber = r.Value }
         }, (log, location) =>
         {
             if (log.LocationInfo == null)
             {
                 log.LocationInfo = location;
             }
         }) }
 })
 {
 }
 public Log4NetLoggingDeserializer()
     : base(new Dictionary <string, Action <LoggingData, XmlReader> >(StringComparer.OrdinalIgnoreCase)
 {
     { "logger", (l, r) => l.LoggerName = r.Value },
     { "domain", (l, r) => l.Domain = r.Value },
     { "username", (l, r) => l.UserName = r.Value },
     { "thread", (l, r) => l.ThreadName = r.Value },
     { "level", (l, r) => l.Level = r.Value },
     { "timestamp", (l, r) => l.TimeStamp = DateTime.Parse(r.Value) },
     { "message", (l, r) => l.Message = r.ReadElementContentAsString() },
     { "properties", ReadProperties },
     { "exception", ReadException },
     { "locationInfo", XmlElementParser.CreateParser <LocationInfo>(new Dictionary <string, Action <LocationInfo, XmlReader> >(StringComparer.OrdinalIgnoreCase)
         {
             { "class", (l, r) => l.ClassName = r.Value },
             { "method", (l, r) => l.MethodName = r.Value },
             { "file", (l, r) => l.FileName = r.Value },
             { "line", (l, r) => l.LineNumber = r.Value }
         }, (log, location) => log.LocationInfo = location) }
 })
 {
 }