コード例 #1
0
        /// <summary>
        /// Read the LexerStyles XML tag with its attributes (if any) and insert
        /// a resulting <seealso cref="HighlightingTheme"/> object into the <seealso cref="HighlightingThemes"/> root object.
        /// </summary>
        internal static void ReadNode(XmlReader reader, HighlightingThemes HlThemeRoot)
        {
            reader.ReadToNextSibling(ReadLexerStyles.XMLName);
            while (reader.Read())
            {
                if (reader.IsStartElement() == true)
                {
                    switch (reader.Name)
                    {
                    case ReadLexerType.XMLName:
                        HighlightingTheme t = ReadLexerType.ReadNode(reader.ReadSubtree());

                        try
                        {
                            HlThemeRoot.AddTheme(t.HlName, t);
                        }
                        catch (Exception e) // Reading one errornous style node should not crash the whole process
                        {
                            logger.Error("Error reading LexerType node", e);
                        }
                        break;

                    case XMLNameSpace:
                        break;

                    default:
                        if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
                        {
                            logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerStyles.XMLName + "' is not implemented.");
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Read the LexerType XML tag with its attributes (if any) and return
        /// a resulting <seealso cref="HighlightingTheme"/> object.
        /// </summary>
        internal static HighlightingTheme ReadNode(XmlReader reader)
        {
            HighlightingTheme hlTheme = null;

            string name = string.Empty;
            string desc = string.Empty;

            reader.ReadToNextSibling(ReadLexerType.XMLName);
            while (reader.MoveToNextAttribute())
            {
                switch (reader.Name)
                {
                case ReadLexerType.attr_name:
                    name = reader.Value;
                    break;

                case XMLNameSpace:
                    break;

                case ReadLexerType.attr_desc:
                    desc = (reader.Value == null ? string.Empty : reader.Value);
                    break;
                }
            }

            hlTheme        = new HighlightingTheme(name);
            hlTheme.HlDesc = desc;


            while (reader.Read())
            {
                if (reader.IsStartElement() == true)
                {
                    switch (reader.Name)
                    {
                    case ReadWordsStyle.XMLName:
                        WordsStyle t = ReadWordsStyle.ReadNode(reader.ReadSubtree());

                        hlTheme.AddWordStyle(t.Name, t);
                        break;

                    case XMLNameSpace:
                        break;

                    default:
                        if (reader.Name.Trim().Length > 0 && reader.Name != XMLComment)
                        {
                            logger.Warn("Parsing the XML child:'" + reader.Name + "' of '" + ReadLexerType.XMLName + "' is not implemented.");
                        }
                        break;
                    }
                }
            }

            return(hlTheme);
        }