コード例 #1
0
        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);
        }
コード例 #2
0
 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");
 }
コード例 #3
0
        internal XmlAttributeTokenInfo(XmlScanner scanner, XmlNamespaceManager nsMgr, XmlNodeType type, bool nor) : this() {
            _NsMgr = nsMgr;
            _Scanner = scanner;        
            _NodeType = type;

            _NormalizeText = nor;
            _HasNormalize = !_NormalizeText;
        }
コード例 #4
0
ファイル: xmlbasictokeninfo.cs プロジェクト: ArildF/masters
 internal XmlBasicTokenInfo(XmlScanner scanner, XmlNamespaceManager nsMgr, XmlNodeType type, int depth) {
     _Scanner = scanner;                
     _NsMgr = nsMgr;        
     _NodeType = type;        
     _Depth = depth;                
     _LineNum = 0;
     _LinePos = 0;
 } 
コード例 #5
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;
        }
コード例 #6
0
ファイル: xmlelementtokeninfo.cs プロジェクト: ArildF/masters
 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;
 }
コード例 #7
0
 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;
 }
コード例 #8
0
ファイル: xmlvaluetokeninfo.cs プロジェクト: ArildF/masters
 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;
 } 
コード例 #9
0
        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;
        }
コード例 #10
0
 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);
         }
     }
 }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: xmlentityreader.cs プロジェクト: ArildF/masters
 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;
 }
コード例 #13
0
 internal virtual void SetName(XmlScanner scanner, String nameWPrefix, int nameColonPos, int depth, bool isDefault) {
     _Scanner = scanner;        
     _Depth = depth;
     _IsDefault = isDefault;    
     _NameWPrefix = nameWPrefix;
 }
コード例 #14
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
 /// <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));
 }
コード例 #15
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
 /// <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);
 }
コード例 #16
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
         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;
        }
コード例 #17
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
        /// <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);

        }
コード例 #18
0
 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);
         }
     }
 }
コード例 #19
0
        public void Load(Stream stream)
        {
            XmlScanner scanner;

            scanner = new XmlScanner(stream);
            try
            {
                this.Load(scanner);
            }
            finally
            {
                scanner.Close();
            }
        }
コード例 #20
0
        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);
                }
            }
        }
コード例 #21
0
        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();
        }
コード例 #22
0
        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;
            }
        }
コード例 #23
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
        //
        // 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());
        }
コード例 #24
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
 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;
     }
 }
コード例 #25
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
 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;
 }
コード例 #26
0
        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());
        }
コード例 #27
0
        public void Load(XmlReader reader)
        {
            XmlScanner scanner;

            scanner = new XmlScanner(reader);
            try
            {
                this.Load(scanner);
            }
            finally
            {
                scanner.Close();
            }
        }
コード例 #28
0
 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);
         }
     }
 }
コード例 #29
0
 protected LogLevelResolver ReadLogPattern(XmlScanner scanner)
 {
     return LogLevelResolvers.LogMatches(
         LogMatchers.NameMatchesPattern(
             scanner.Text().Trim()),
         scanner.GetAttributeAsEnum<LogLevel>(
             typeof(LogLevel),
             "level",
             true));
 }
コード例 #30
0
ファイル: xmltextreader.cs プロジェクト: ArildF/masters
        // 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;
        }