本文整理汇总了C#中IdentifierExpression.Member方法的典型用法代码示例。如果您正苦于以下问题:C# IdentifierExpression.Member方法的具体用法?C# IdentifierExpression.Member怎么用?C# IdentifierExpression.Member使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdentifierExpression
的用法示例。
在下文中一共展示了IdentifierExpression.Member方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceStringLiteralsWithVariables
public static string ReplaceStringLiteralsWithVariables(string text, IEnumerable<string> macros, Func<int, int, string, string, string> onReplace)
{
var setting = new CompilerSettings();
foreach (var macro in macros) setting.ConditionalSymbols.Add(macro);
var tree = SyntaxTree.Parse(text, string.Empty, setting);
tree.Freeze();
var doc = new StringBuilderDocument(text);
using (var editor = new DocumentScript(doc, FormattingOptionsFactory.CreateAllman(), TextEditorOptions.Default)) {
var originDoc = editor.OriginalDocument;
foreach (var node in tree.Descendants.OfType<PrimitiveExpression>().Where(e => e.Value is string)) {
var line = originDoc.GetLineByNumber(node.StartLocation.Line);
var result = onReplace(node.StartLocation.Line, node.StartLocation.Column, originDoc.GetText(line), node.Value as string);
if (result != null) {
var names = result.Split('.');
Expression exp = new IdentifierExpression(names.First());
foreach (var name in names.Skip(1)) exp = exp.Member(name);
editor.Replace(node, exp);
}
}
}
return doc.Text;
}