本文整理汇总了C#中InvocationExpression.Annotation方法的典型用法代码示例。如果您正苦于以下问题:C# InvocationExpression.Annotation方法的具体用法?C# InvocationExpression.Annotation怎么用?C# InvocationExpression.Annotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InvocationExpression
的用法示例。
在下文中一共展示了InvocationExpression.Annotation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CouldBeExpressionTree
public static bool CouldBeExpressionTree(InvocationExpression expr)
{
if (expr != null && expr.Arguments.Count == 2) {
IMethod mr = expr.Annotation<IMethod>();
return mr != null && mr.Name == "Lambda" && mr.DeclaringType.FullName == "System.Linq.Expressions.Expression";
}
return false;
}
示例2: VisitInvocationExpression
public override StringBuilder VisitInvocationExpression(InvocationExpression invocationExpression, int data)
{
var result = new StringBuilder();
var mref = invocationExpression.Annotation<MethodReference>();
var m = mref != null ? mref.Resolve() : invocationExpression.Annotation<MethodDefinition>();
if (m.DeclaringType.MetadataToken.ToInt32() == typeof(ShaderDefinition).MetadataToken)
return VisitShaderDefCall(m, invocationExpression);
RegisterMethod(m);
result.Append(Shader.GetMethodName(m));
result.Append("(").Append(ArgsToString(invocationExpression.Arguments)).Append(")");
return result;
}
示例3: VisitInvocationExpression
public override void VisitInvocationExpression (InvocationExpression invocationExpression)
{
base.VisitInvocationExpression (invocationExpression);
var mr = invocationExpression.Target as MemberReferenceExpression;
if (mr == null)
return;
if (mr.MemberName != "Equals")
return;
var m = invocationExpression.Annotation<MemberReference> ();
if (m.DeclaringType.FullName != "System.Object")
return;
var i = new InvocationExpression (
new MemberReferenceExpression (new TypeReferenceExpression (new SimpleType ("NObject")), "GenericEquals"),
mr.Target.Clone (), invocationExpression.Arguments.First ().Clone ());
invocationExpression.ReplaceWith (i);
}
示例4: VisitInvocationExpression
public override void VisitInvocationExpression(InvocationExpression e)
{
var md = e.Annotation<MethodDefinition>();
if (md != null && (md.IsGetter || md.IsSetter))
{
var p = md.DeclaringType.Properties.FirstOrDefault(x => x.GetMethod == md || x.SetMethod == md);
if (p != null)
{
// 转换为属性访问
var target = (e.Target as MemberReferenceExpression).Target;
if (p.IsIndexer())
{
IndexerExpression ie = new IndexerExpression(target.Detach()).WithAnnotation(p);
e.Arguments.MoveTo(ie.Arguments);
e.ReplaceWith(ie);
}
else
{
//MemberReferenceExpression mre = new MemberReferenceExpression(target.Detach(), p.Name).WithAnnotation(p);
}
}
}
//[CompilerGenerated]
//private sealed class C_e_5
//{
// public Action f_1_E2DC5B04;
// public void M_1_void(object x)
// {
// this.f_1_E2DC5B04();
// }
//}
//
//public ActionCommand(Action execute)
//{
// Action<object> action = null;
// ActionCommand.C_e_5 c_e_ = new ActionCommand.C_e_5();
// c_e_.f_1_E2DC5B04 = execute;
// if (action == null)
// {
// action = new Action<object>(c_e_.M_1_void);
// }
// base..ctor(action);
//}
//
//====>
//public ActionCommand(Action execute) : base(x=>execute())
//{
//}
base.VisitInvocationExpression(e);
}