コード例 #1
0
        /// <summary>
        /// Add a regex depending on three nodes
        /// </summary>
        /// <param name="languageNode">The language node</param>
        /// <param name="subNode">The first sub-node</param>
        /// <param name="subNode2">The second sub-node</param>
        /// <param name="sRegExp">The regular expression string</param>
        /// <exception cref="ArgumentNullException">This is thrown if a node
        /// parameter is null or the regular expression is null.</exception>
        /// <exception cref="ArgumentException">This is thrown if a node
        /// parameter does not have an 'id' attribute or if the regular
        /// expression could not be created.</exception>
        internal void AddKey(XmlNode languageNode, XmlNode subNode,
                             XmlNode subNode2, string sRegExp)
        {
            Regex regExp = new Regex(sRegExp,
                                     RegexDictionary.GetRegexOptions(languageNode));

            if (regExp == null)
            {
                throw new ArgumentException(
                          "Could not create regular expression");
            }

            dictionary.Add(RegexDictionary.KeyName(languageNode, subNode,
                                                   subNode2), regExp);
        }
コード例 #2
0
ファイル: CodeColorizer.cs プロジェクト: julianhaslinger/SHFB
        //=====================================================================

        /// <summary>
        /// Load the language file and preprocess it. Also loads the XSL file.
        /// </summary>
        /// <remarks>Call this method to reload the language files and reset the colorizer to its default
        /// state.</remarks>
        public void Init()
        {
            numberLines = outlining = false;
            useDefaultTitle = true;
            defaultTabSize = 8;
            copyText = "Copy";
            copyImageUrl = "CopyCode.gif";

            rxDic = new RegexDictionary();

            // Load and preprocess language data
            languageSyntax = new XmlDocument();
            friendlyNames.Clear();
            alternateIds.Clear();
            this.BuildSyntax();

            // Load XSL
            languageStyle = new XslCompiledTransform();
            languageStyle.Load(this.LanguageStyleFileName);
        }
コード例 #3
0
 /// <summary>
 /// Retrieves the regular expression out of 3 nodes
 /// </summary>
 /// <param name="languageNode">The language node</param>
 /// <param name="subNode">The first sub-node</param>
 /// <param name="subNode2">The second sub-node</param>
 /// <returns>The regular expression</returns>
 /// <exception cref="ArgumentNullException">This is thrown if a node
 /// parameter is null or the regular expression is null.</exception>
 /// <exception cref="ArgumentException">This is thrown if a node
 /// parameter does not have an 'id' attribute.</exception>
 internal Regex GetKey(XmlNode languageNode, XmlNode subNode,
                       XmlNode subNode2)
 {
     return(dictionary[RegexDictionary.KeyName(languageNode, subNode,
                                               subNode2)]);
 }
コード例 #4
0
ファイル: CodeColorizer.cs プロジェクト: aeagle/SHFB
        //=====================================================================

        /// <summary>
        /// Load the language file and preprocess it. Also loads the XSL file.
        /// </summary>
        /// <remarks>Call this method to reload the language files and reset the colorizer to its default
        /// state.</remarks>
        public void Init()
        {
            if(languageSyntaxFileName == null)
            {
                this.LoadDefaultConfigFiles();

                // This gets called again when loading the default configuration files so we can just return here
                return;
            }

            numberLines = outlining = false;
            useDefaultTitle = true;
            defaultTabSize = 8;
            copyText = "Copy";
            copyImageUrl = "CopyCode.gif";

            rxDic = new RegexDictionary();

            // Load and preprocess language data
            languageSyntax = new XmlDocument();
            friendlyNames.Clear();
            alternateIds.Clear();
            this.BuildSyntax();

            // Load XSL
            languageStyle = new XslCompiledTransform();
            languageStyle.Load(this.LanguageStyleFileName);
        }