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 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"); }
internal XmlAttributeTokenInfo(XmlScanner scanner, XmlNamespaceManager nsMgr, XmlNodeType type, bool nor) : this() { _NsMgr = nsMgr; _Scanner = scanner; _NodeType = type; _NormalizeText = nor; _HasNormalize = !_NormalizeText; }
internal XmlBasicTokenInfo(XmlScanner scanner, XmlNamespaceManager nsMgr, XmlNodeType type, int depth) { _Scanner = scanner; _NsMgr = nsMgr; _NodeType = type; _Depth = depth; _LineNum = 0; _LinePos = 0; }
internal override void SetName(XmlScanner scanner, int offset, int length, int colon, int depth) { _Scanner = scanner; _NameColonPos = colon; _Depth = depth; _NameWPrefix = _Scanner.GetTextAtom(offset,length); _SchemaType = null; _TypedValue = null; }
internal void SetName(String nameWPrefix, String localName, String prefix, String ns, int depth, XmlScanner scanner) { _NameWPrefix = nameWPrefix; _Name = localName; _Prefix = prefix; _NamespaceURI = ns; _Depth = depth; _Scanner = scanner; }
internal XmlNSElementTokenInfo(XmlScanner scanner, XmlNamespaceManager nsMgr, XmlNodeType type, String name, int nameOffset, int nameLength, int nameColonPos, int depth, bool isEmpty) : base(scanner, nsMgr, type, depth) { _NsMgr = nsMgr; _Scanner = scanner; _NameColonPos = nameColonPos; _NameWPrefix = String.Empty; _Name = String.Empty; _Prefix = String.Empty; _NamespaceURI = String.Empty; }
internal XmlValueTokenInfo(XmlScanner scanner, XmlNamespaceManager nsMgr, XmlNodeType type, int depth, bool nor) : base(scanner, nsMgr, type, depth) { _ValueOffset = -1; _ValueLength = -1; _Value = null; _StringBuilder = null; _RawValue = String.Empty; _NormalizeText = nor; _HasNormalize = !_NormalizeText; }
internal void SetValue(XmlScanner scanner, String value, int offset, int length) { _Scanner = scanner; _ExpandValue = value; _Value = null; _IgnoreValue = null; _ValueOffset = offset; _ValueLength = length; _RawValue = value; _HasNormalize = !_NormalizeText; _SchemaType = null; _TypedValue = null; }
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); }
internal XmlEntityReader(XmlScanner scanner, XmlNameTable nt, XmlNamespaceManager nsMgr, XmlNodeType node, String entityName, int depth, Encoding encoding, String baseURI, bool isExternal, bool isAttributeText, bool standAlone, String originalBaseURI) : base((scanner == null ? new XmlScanner(new StringReader("a"), nt) : scanner), nt, nsMgr, node, depth, encoding, baseURI, isExternal, standAlone) { if (scanner == null) { _IsScanner = false; _AttributeTextToken = new XmlNSAttributeTokenInfo(_Scanner, _NsMgr, XmlNodeType.Text, Normalization, _XmlNs); _AttributeTextToken.Value = String.Empty; _AttributeTextToken.Depth = depth + 1; } else { _IsScanner = true; } _IsExternal = isExternal; //We only need to return the EndEntity token when EntityHandling = ExpandCharEntity _EndEntityToken = new XmlNameValueTokenInfo(_Scanner, _NsMgr, XmlNodeType.EndEntity, depth-1, String.Empty, false); _EndEntityToken.Name = entityName; _EndEntityEncoding = encoding; _IsAttributeText = isAttributeText; _PrevXmlSpace = XmlSpace.None; _PrevXmlLang = String.Empty; _OriginalBaseUri = originalBaseURI; }
internal virtual void SetName(XmlScanner scanner, String nameWPrefix, int nameColonPos, int depth, bool isDefault) { _Scanner = scanner; _Depth = depth; _IsDefault = isDefault; _NameWPrefix = nameWPrefix; }
/// <include file='doc\XmlTextReader.uex' path='docs/doc[@for="XmlTextReader.XmlTextReader9"]/*' /> /// <devdoc> /// </devdoc> public XmlTextReader(string url, TextReader input, XmlNameTable nt) : this(nt) { _NsMgr = new XmlNamespaceManager( _NameTable ); _Scanner = new XmlScanner(input, _NameTable); _BaseURI = (url==null? String.Empty: NameTable.Add(url)); }
/// <include file='doc\XmlTextReader.uex' path='docs/doc[@for="XmlTextReader.XmlTextReader10"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlTextReader(Stream xmlFragment, XmlNodeType fragType, XmlParserContext context) : this(null == context || null == context.NameTable ? new NameTable() : context.NameTable ) { _Scanner = new XmlScanner(new XmlStreamReader(xmlFragment), _NameTable, (null == context ? null : context.Encoding)); InitFragmentReader(fragType, context); }
private bool ReturnWhitespaceToken(XmlScanner scanner) { bool returnWS = false; if (_WhitespaceHandling == WhitespaceHandling.None) { goto cleanup; } if (_LastElementInfo == null) { _WhitespaceToken.NodeType = XmlNodeType.Whitespace; } else { _WhitespaceToken.NodeType = this.CheckWhitespaceNodeType; } if (_WhitespaceToken.NodeType == XmlNodeType.Whitespace && _WhitespaceHandling != WhitespaceHandling.All) { goto cleanup; } _WhitespaceToken.SetValue(scanner, null, scanner.StartPos, scanner.TextLength); _WhitespaceToken.LineNum = _Scanner.LineNum; _WhitespaceToken.LinePos = _Scanner.LinePos; returnWS = true; cleanup: return returnWS; }
/// <include file='doc\XmlTextReader.uex' path='docs/doc[@for="XmlTextReader.XmlTextReader11"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public XmlTextReader(String xmlFragment, XmlNodeType fragType, XmlParserContext context) : this(null == context || null == context.NameTable ? new NameTable() : context.NameTable ) { _Scanner = new XmlScanner(xmlFragment.ToCharArray(), _NameTable); InitFragmentReader(fragType, context); }
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); } } }
public void Load(Stream stream) { XmlScanner scanner; scanner = new XmlScanner(stream); try { this.Load(scanner); } finally { scanner.Close(); } }
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 LoadAppenderPipeline(XmlScanner scanner) { FormatAppender before; FormatAppender after; before = (FormatAppender)this._manager.Appender.Unwrap( typeof(FormatAppender)); this._manager.Appender = this.ReadAppenderPipeline(scanner); after = (FormatAppender)this._manager.Appender.Unwrap( typeof(FormatAppender)); if (before != null && after != null) { after.NewLine = before.NewLine; after.MessageFormat = before.MessageFormat; after.FrameFormat = before.FrameFormat; after.CauseFormat = before.CauseFormat; } }
// // functions handle DTDParser, DTD and schema Validation // private String ParseDtd( XmlScanner scanner ) { if (_DtdParser == null) _DtdParser = new DtdParser(scanner, (XmlReader)this, this.GetResolver(), _NameTable, _ValidationEventHandler, _CheckNamespaces); _DtdParser.Parse(); return _NameTable.Add(_DtdParser.GetSchemaInfo().DocTypeName.ToString()); }
private void CreateScanner() { Stream stream = null; XmlResolver myResolver = (_XmlResolver != null ? _XmlResolver : new XmlUrlResolver()); Uri uri = myResolver.ResolveUri(null, _BaseURI); try { stream = (Stream)myResolver.GetEntity(uri, null,null); _Scanner = new XmlScanner(new XmlStreamReader(stream), _NameTable); } catch { if (stream != null) stream.Close(); throw; } }
internal XmlTextReader(XmlScanner scanner, XmlNameTable nt, XmlNamespaceManager nsMgr, XmlNodeType nodeType, int depth, Encoding encoding, String baseURI, bool external, bool standAlone) : this(nt) { _Scanner = scanner; _NsMgr = nsMgr; _BaseURI = baseURI==null? String.Empty : _NameTable.Add(XmlUrlResolver.UnEscape(baseURI)); _RootCount = 1; _NextState = 2; _ElementDepth = -1; _EntityDepthOffset = depth; _Encoding = encoding; _PartialContent = true; // Even thought it doesn't seem like it, we are infact parsing xml fragment with this constructor. // this constructor is used when we encounter an entity that points to an external file and // the external file contains element content. _PartialContentNodeType = nodeType; _IsExternal = external; _StandAlone = standAlone; }
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()); }
public void Load(XmlReader reader) { XmlScanner scanner; scanner = new XmlScanner(reader); try { this.Load(scanner); } finally { scanner.Close(); } }
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 LogLevelResolver ReadLogPattern(XmlScanner scanner) { return LogLevelResolvers.LogMatches( LogMatchers.NameMatchesPattern( scanner.Text().Trim()), scanner.GetAttributeAsEnum<LogLevel>( typeof(LogLevel), "level", true)); }
// Following constructor assumes that the fragment node type == XmlDecl // We handle this node type separately because there is not real way to determine what the // "innerXml" of an XmlDecl is. This internal function is required by DOM. When(if) we handle/allow // all nodetypes in InnerXml then we should support them as part of fragment constructor as well. // Until then, this internal function will have to do. internal XmlTextReader(String xmlFragment, XmlParserContext context) : this(null == context || null == context.NameTable ? new NameTable() : context.NameTable ) { String input = "<?xml " + xmlFragment + "?>"; _Scanner = new XmlScanner(input.ToCharArray(), _NameTable); InitFragmentReader(XmlNodeType.Document, context); _PartialContentNodeType = XmlNodeType.XmlDeclaration; }