상속: CSharpSyntaxRewriter
예제 #1
0
 public static string ReplaceStringLiteralsWithVariables(string text, IEnumerable<string> macros, Func<int, int, string, string, string> onReplace)
 {
     var sourceText = SourceText.From(text);
     var tree = CSharpSyntaxTree.ParseText(sourceText, new CSharpParseOptions(preprocessorSymbols: macros));
     var newRoot = new StringLiteralToVariableRewriter() { OnRewrite = onReplace, Source = sourceText, }.Visit(tree.GetRoot());
     return tree.WithRootAndOptions(newRoot, tree.Options).ToString();
 }
예제 #2
0
        public static string ReplaceStringLiteralsWithVariables(string text, IEnumerable <string> macros, Func <int, int, string, string> onReplace)
        {
            var tree    = CSharpSyntaxTree.ParseText(text, new CSharpParseOptions(preprocessorSymbols: macros));
            var newRoot = new StringLiteralToVariableRewriter()
            {
                OnRewrite = onReplace
            }.Visit(tree.GetRoot());

            return(tree.WithRootAndOptions(newRoot, tree.Options).ToString());
        }