本文整理汇总了C#中LanguageElement.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# LanguageElement.Clone方法的具体用法?C# LanguageElement.Clone怎么用?C# LanguageElement.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LanguageElement
的用法示例。
在下文中一共展示了LanguageElement.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGeneratedCode
private static string GetGeneratedCode(LanguageElement originalCall)
{
if (!(originalCall is IHasArguments))
return null;
ExpressionCollection originalArguments = (originalCall as IHasArguments).Arguments;
if (originalArguments == null)
return null;
LanguageElement replacementCall = originalCall.Clone() as LanguageElement;
(replacementCall as IHasArguments).Arguments.Clear();
IWithParameters declaration = GetValidDeclaration(originalCall);
if (declaration == null ||
!(declaration.Parameters.Count == originalArguments.Count ||
(declaration.Parameters.Count == originalArguments.Count + 1 && HasParamArray(declaration))
|| (declaration.Parameters.Count == originalArguments.Count + 1 && IsExtensionMethod(declaration))
))
return null;
int startParamIndex = 0;
if (IsExtensionMethod(declaration))
startParamIndex = 1;
for (int i = 0; i < originalArguments.Count; i++)
{
Expression originalArgument = originalArguments[i];
AttributeVariableInitializer namedArgument = originalArgument as AttributeVariableInitializer;
if (namedArgument == null)
{
ElementReferenceExpression leftSide = new ElementReferenceExpression(declaration.Parameters[startParamIndex + i].Name);
namedArgument = new AttributeVariableInitializer();
namedArgument.LeftSide = leftSide;
namedArgument.RightSide = originalArgument.Clone() as Expression;
}
(replacementCall as IHasArguments).Arguments.Add(namedArgument);
}
return CodeRush.CodeMod.GenerateCode(replacementCall, true);
}