protected void LoadUseField(XmlScanner scanner) { Dictionary <string, string> properties; properties = new Dictionary <string, string>(); foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "Property": properties[child.GetAttributeAsString("name")] = child.Text(); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/> in <Field/>", child.Name); } } this.Set( scanner.GetAttributeAsString("name"), scanner.Parent.GetAttributeAsString("name"), properties); }
protected void LoadLog(XmlScanner scanner) { List <LogLevelResolver> list; list = new List <LogLevelResolver>(); if (!scanner.GetAttributeAsBoolean("reset", false)) { LogLevelResolver[] remaining; remaining = this._manager.LogLevelResolvers; foreach (LogLevelResolver resolver in remaining) { list.Add(resolver); } } foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "Pattern": list.Add(this.ReadLogPattern(child)); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/> in <Log/>", child.Name); } } this._manager.Update(list.ToArray()); }
protected Appender ReadAppenderPipeline(XmlScanner scanner) { foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "Synchronized": return(new Synchronized( this.ReadAppenderPipeline(child))); case "AutoFlush": return(new AutoFlush( this.ReadAppenderPipeline(child))); case "CloseShield": return(new CloseShield( this.ReadAppenderPipeline(child))); case "Final": return(this.ReadAppenderPipelineFinal(child)); default: throw child.CreateXmlException( "unexpected element <{0}/> in appender pipeline", child.Name); } } throw scanner.CreateXmlException( "missing <Final/> in appender pipeline"); }
protected void LoadAppender(XmlScanner scanner) { foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "Pipeline": this.LoadAppenderPipeline(child); break; case "Format": this.LoadAppenderFormat(child); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/> in <Appender/>", child.Name); } } }
protected void Load(XmlScanner scanner) { foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "LogProcessId": this._manager.LogProcessId = child.GetAttributeAsBoolean("value"); break; case "LogManagedThreadId": this._manager.LogManagedThreadId = child.GetAttributeAsBoolean("value"); break; case "LogFrameDepth": this._manager.LogFrameDepth = child.GetAttributeAsInt32("value"); break; case "LogExtendedFrame": this._manager.LogExtendedFrame = child.GetAttributeAsBoolean("value"); break; case "Appender": this.LoadAppender(child); break; case "Log": this.LoadLog(child); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/>", child.Name); } } }
protected void LoadAppenderFormat(XmlScanner scanner) { FormatAppender formatter; formatter = (FormatAppender)this._manager.Appender.Unwrap( typeof(FormatAppender)); if (formatter == null) { return; } foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "NewLine": formatter.NewLine = this.ReadAppenderFormat(child); break; case "Message": formatter.MessageFormat = this.ReadAppenderFormat(child); break; case "Frame": formatter.FrameFormat = this.ReadAppenderFormat(child); break; case "Cause": formatter.CauseFormat = this.ReadAppenderFormat(child); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/> in <Format/>", child.Name); } } }
protected string ReadAppenderFormat(XmlScanner scanner) { StringBuilder builder; builder = new StringBuilder(); foreach (XmlScanner child in scanner.Read()) { if (child.IsElement) { switch (child.Name) { case "Space": builder.Append(' '); break; case "CarriageReturn": builder.Append('\r'); break; case "LineFeed": builder.Append('\n'); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/> in format text", child.Name); } } else { string[] lines; lines = child.Value.Split( _readAppenderFormatNewLineChars, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines) { builder.Append(line.Trim()); } } } return(builder.ToString()); }
protected void Load(XmlScanner scanner) { foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } switch (child.Name) { case "Use": this.LoadUse(child); break; default: throw scanner.CreateXmlException( "unexpected element <{0}/>", child.Name); } } }
protected Appender ReadAppenderPipelineFinal(XmlScanner scanner) { Dictionary <string, string> properties; properties = new Dictionary <string, string>(); foreach (XmlScanner child in scanner.Read()) { if (!child.IsElement) { continue; } if (child.Name != "Property") { throw scanner.CreateXmlException( "unexpected element <{0}/> in <Final/>", child.Name); } properties[child.GetAttributeAsString("name")] = child.Text(); } return(this.CreateAppenderPipelineFinal( scanner.GetAttributeAsString("name"), properties)); }