private string RewriteRule(RewriteRule rule, Uri contextUri, string content)
        {
            var specRule = rule.ReplaceToken(contextUri);

            Regex regex = new Regex(specRule.Match.ToString(), RegexOptions.IgnoreCase);
            var replacedContent = regex.Replace(content, specRule.Replace.ToString());

            return replacedContent;
        }
Example #2
0
        //todo require refactor
        public static RewriteRule ReplaceToken(this RewriteRule tokenRule, Uri contextUri)
        {
            var match = tokenRule.Match.ToString();
            var replace = tokenRule.Replace.ToString();
            if (!match.Contains("{") && !replace.Contains("{")) // no token inside, quick skip
                return tokenRule;

            RewriteRule rule = new RewriteRule();
            rule.Match = new Match(StringReplace(match, contextUri));
            rule.Replace = new Replace(StringReplace(replace, contextUri));

            return rule;
        }