private List <PreprocessRuleInfo> ReadPreprocessInfo(string ResourceName)
        {
            List <PreprocessRuleInfo> results = new List <PreprocessRuleInfo>();

            string content = Utils.Utils.ReadEmbeddedResourceFile(ResourceName);

            string[] lines = content.Split("\r\n".ToCharArray());

            foreach (string line in lines)
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }
                string[] tmps = line.Split('\t');

                if (tmps.Length == 3)
                {
                    PreprocessRuleInfo info = new PreprocessRuleInfo();
                    info.ValueRegex = tmps[0];
                    info.OrigValue  = tmps[1];
                    info.NewValue   = tmps[2];

                    results.Add(info);
                }
            }

            return(results);
        }
Example #2
0
        public static string ReplaceRegx(PreprocessRuleInfo info, string text)
        {
            if (string.IsNullOrWhiteSpace(text) || info == null)
            {
                return(text);
            }

            string result = text;

            List <string> matchedValues = Match(info.ValueRegex, text);

            foreach (string machtedValue in matchedValues)
            {
                result = Regex.Replace(text, info.OrigValue, info.NewValue, RegexOptions.IgnoreCase);
            }

            return(result);
        }