本文整理汇总了C#中MemberReferenceExpression.ReplaceWith方法的典型用法代码示例。如果您正苦于以下问题:C# MemberReferenceExpression.ReplaceWith方法的具体用法?C# MemberReferenceExpression.ReplaceWith怎么用?C# MemberReferenceExpression.ReplaceWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberReferenceExpression
的用法示例。
在下文中一共展示了MemberReferenceExpression.ReplaceWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitMemberReferenceExpression
public override void VisitMemberReferenceExpression(MemberReferenceExpression memberReferenceExpression)
{
if (this.m_Mappings.ContainsKey(memberReferenceExpression.MemberName))
{
if (memberReferenceExpression.Target is ThisReferenceExpression)
{
memberReferenceExpression.ReplaceWith(
new IdentifierExpression(
this.m_Mappings[memberReferenceExpression.MemberName]));
return;
}
}
base.VisitMemberReferenceExpression(memberReferenceExpression);
}
示例2: VisitMemberReferenceExpression
public override void VisitMemberReferenceExpression(MemberReferenceExpression e)
{
var md = e.Annotation<MethodDefinition>();
if (md != null && md.IsPrivate && md.IsCompilerGenerated())
{
//public override void OnMasterMouseLeave(ModifierMouseArgs e)
//{
// this.TB(ModifierGroup.YB, e);
//}
//
//[CompilerGenerated]
//private static void YB(IChartModifier x, ModifierEventArgsBase y)
//{
// x.OnMasterMouseLeave((ModifierMouseArgs)y);
//}
//
//====>
//public override void OnMasterMouseLeave(ModifierMouseArgs e)
//{
// this.TB((x, y) => x.OnMasterMouseLeave((ModifierMouseArgs)y), e);
//}
var td = e.Ancestors.OfType<TypeDeclaration>().FirstOrDefault();
if (td != null)
{
var method = td.Members.OfType<MethodDeclaration>().FirstOrDefault(x => x.Annotation<MethodDefinition>() == md);
if (method != null)
{
LambdaExpression le = new LambdaExpression();
var body = method.Body;
if (body.Statements.Count == 1)
{
le.Body = TryReduceLambdaBody(body.Statements.First()).Detach();
}
else
{
le.Body = body.Detach();
}
// 设置 Lambda 函数参数
if (method.Parameters.Count > 0)
{
var prmNames = new[] { "x", "y", "z", "u", "v", "w", "m", "n", "p", "q", "r", "s", "t" };
var usedNames = new HashSet<string>(body.Descendants.OfType<IdentifierExpression>().Select(x => x.Identifier).Distinct());
var index = 0;
foreach (var x in method.Parameters)
{
var pn = index < prmNames.Length ? prmNames[index] : "e" + index.ToString();
index++;
while (usedNames.Contains(pn))
{
pn = index < prmNames.Length ? prmNames[index] : "e" + index.ToString();
index++;
}
foreach (var r in le.Body.Descendants.OfType<IdentifierExpression>().Where(r => r.Identifier == x.Name))
{
r.Identifier = pn;
}
le.Parameters.Add(new ParameterDeclaration(pn));
}
}
DelayRemove(method);
e.ReplaceWith(le);
}
}
}
base.VisitMemberReferenceExpression(e);
}