本文整理汇总了C#中InvocationExpression.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# InvocationExpression.Clone方法的具体用法?C# InvocationExpression.Clone怎么用?C# InvocationExpression.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InvocationExpression
的用法示例。
在下文中一共展示了InvocationExpression.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFormatCallToInvocation
void AddFormatCallToInvocation (RefactoringContext context, Script script, PrimitiveExpression pExpr, InvocationExpression invocation)
{
var newInvocation = (InvocationExpression)invocation.Clone ();
newInvocation.Arguments.First ().ReplaceWith (CreateFormatString (context, pExpr, newInvocation.Arguments.Count () - 1));
newInvocation.Arguments.Add (CreateFormatArgument (context));
script.Replace (invocation, newInvocation);
}
示例2: AddArgument
void AddArgument(Script script, InvocationExpression invocationExpression, string stringComparison)
{
var astBuilder = ctx.CreateTypeSytemAstBuilder(invocationExpression);
var newArgument = astBuilder.ConvertType(new TopLevelTypeName("System", "StringComparison")).Member(stringComparison);
var copy = (InvocationExpression)invocationExpression.Clone();
copy.Arguments.Add(newArgument);
script.Replace(invocationExpression, copy);
}
示例3: VisitInvocationExpression
public override void VisitInvocationExpression (InvocationExpression invocationExpression)
{
base.VisitInvocationExpression (invocationExpression);
var hasRefs = invocationExpression.Arguments.OfType<DirectionExpression> ().Any ();
if (hasRefs) {
var args = invocationExpression.Arguments.OfType<DirectionExpression> ().ToList ();
var target = invocationExpression.Target;
var lblock = new BlockStatement {
};
for (int i = 0; i < args.Count; i++) {
var a = args [i];
var vname = "_p" + i;
var va = new VariableDeclarationStatement (AstType.Null, vname, new ArrayCreateExpression {
Initializer = new ArrayInitializerExpression (a.Expression.Clone ())
});
a.ReplaceWith (new IdentifierExpression (vname));
lblock.Add (va);
}
var rname = "_r";
var ra = new VariableDeclarationStatement (AstType.Null, rname, invocationExpression.Clone ());
lblock.Add (ra);
for (int i = 0; i < args.Count; i++) {
var a = args [i];
var vname = "_p" + i;
var va = new AssignmentExpression (a.Expression.Clone (),
new IndexerExpression (
new IdentifierExpression (vname), new PrimitiveExpression (0)));
lblock.Add (va);
}
lblock.Add (new ReturnStatement (new IdentifierExpression (rname)));
var lambda = new LambdaExpression {
Body = lblock,
};
var ilambda = new InvocationExpression (lambda);
invocationExpression.ReplaceWith (ilambda);
}
}