Example #1
0
        //=====================================================================

        /// <summary>
        /// Default constructor
        /// </summary>
        /// <remarks>Unless specified via the properties, the default language and style files will be retrieved
        /// from the application configuration file on first use.</remarks>
        /// <overloads>There are two overloads for the constructor.</overloads>
        public CodeColorizer()
        {
#if DEBUG
            timer = new AvgTimer();
#endif
            // Replace function delegate
            replaceByCodeDelegate = new MatchEvaluator(ReplaceByCode);

            // Collapsible region tracking list
            regions = new List<CollapsibleRegion>();

            // See tag preservation
            seeTags = new List<string>();
            onSeeTagFound = new MatchEvaluator(OnSeeTagFound);
            onMarkerFound = new MatchEvaluator(OnMarkerFound);

            // Friendly name dictionary
            friendlyNames = new Dictionary<string, string>();
            alternateIds = new Dictionary<string, string>();
        }
        /// <summary>Load language files and preprocess them. Loads xsl file.</summary>
        /// <remarks>Call this method to reload the language files.</remarks>
        public bool Init()
        {
            // Replace function delegate
            ReplaceByCodeDelegate = new System.Text.RegularExpressions.MatchEvaluator( ReplaceByCode );

            // hashtable for regular expressions
            RxDic = new Collections.RegexDictionary();

            // prepare tags
            EndOfLine="\n";
            OpeningTag = "<";
            ClosingTag = ">";
            Tag = "pre";
            LangTag = "lang";
            InBox=true;

            Timer = new AvgTimer();

            try
            {
                // load and preprocess language data
                LanguageSyntax=new XmlDocument();
                BuildSyntax( );
                // load xsl..
                LanguageStyle=new XslTransform();
                LanguageStyle.Load( LanguageStyleFileName );
                return true;
            }
            catch(Exception e)
            {
                Log.Fatal(e);
                throw e;
            }
        }