本文整理汇总了C#中MethodCall类的典型用法代码示例。如果您正苦于以下问题:C# MethodCall类的具体用法?C# MethodCall怎么用?C# MethodCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodCall类属于命名空间,在下文中一共展示了MethodCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitMethodCall
public override void VisitMethodCall(MethodCall call)
{
var memberBinding = (MemberBinding)call.Callee;
var member = memberBinding.BoundMember;
if (member.NodeType == NodeType.Method)
{
var method = (Method)member;
foreach (var dontPassParameterType in Settings.DontPassParameterType)
{
if (dontPassParameterType.FullName == method.FullName)
{
var infos = Enumerable.Range(1, method.Parameters.Count).GroupJoin(
dontPassParameterType.ParameterType,
index => index,
info => info.Key,
(index, info) => info.FirstOrDefault(i => i.Key == index).Value)
.ToList();
for (var index = 0; index < method.Parameters.Count; index++)
{
string value;
if (dontPassParameterType.ParameterType.TryGetValue(index + 1, out value))
{
if (call.Operands[index].Type.FullName == value)
{
this.Violate(call, method.FullName, index + 1, value);
}
}
}
}
}
}
base.VisitMethodCall(call);
}
示例2: GenerateMethod
private static void GenerateMethod()
{
Method method = new Method();
method.Name = "MyNewProc";
method.MethodType = MethodTypeEnum.Void;
Param newParam = new Param();
TypeReferenceExpression newTypeReferenceExpression = new TypeReferenceExpression();
newTypeReferenceExpression.Name = CodeRush.Language.GetSimpleTypeName("System.Int32");
newParam.MemberTypeReference = newTypeReferenceExpression;
newParam.Name = "MyKillerParameter";
method.Parameters.Add(newParam);
MethodCall statement = new MethodCall();
statement.Name = "Start";
//UnaryIncrement newUnaryIncrement = new UnaryIncrement();
//ElementReferenceExpression elementReferenceExpression = new ElementReferenceExpression(newParam.Name);
//newUnaryIncrement.Expression = elementReferenceExpression;
//statement.AddDetailNode(newUnaryIncrement);
//int MyKillerParameter = 0;
//MyKillerParameter++;
method.AddNode(statement);
string newCode = CodeRush.Language.GenerateElement(method);
TextDocument activeTextDocument = CodeRush.Documents.ActiveTextDocument;
if (activeTextDocument == null)
return;
activeTextDocument.InsertText(activeTextDocument.ActiveView.Caret.SourcePoint, newCode);
}
示例3: VisitMethodCall
/// <summary>Visits a method call.</summary>
/// <param name="methodCall">Method call.</param>
/// <returns>Resulting expression to visit.</returns>
public override void VisitMethodCall(MethodCall methodCall)
{
if (methodCall != null)
{
MemberBinding callBinding = methodCall.Callee as MemberBinding;
if (callBinding != null)
{
/*
typeof(DataServiceCollection<>) is compiled to IL as:
ldtoken [Microsoft.OData.Client]Microsoft.OData.Client.DataServiceCollection`1
call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
*/
Method method = callBinding.BoundMember as Method;
if (method.Name.Name == "GetTypeFromHandle" &&
method.DeclaringType.FullName == "System.Type")
{
Debug.Assert(methodCall.Operands.Count == 1);
Debug.Assert(methodCall.Operands[0].NodeType == NodeType.Ldtoken);
ClassNode classType = (((Literal)(((UnaryExpression)methodCall.Operands[0]).Operand)).Value) as ClassNode;
if (classType != null && classType.FullName == "Microsoft.OData.Client.DataServiceCollection`1")
{
if (methodUnderCheck.DeclaringType.FullName != "System.Data.Serices.Client.WebUtil" &&
methodUnderCheck.Name.Name != "GetDataServiceCollectionOfTType")
{
this.Problems.Add(new Problem(GetResolution(methodUnderCheck.FullName)));
}
}
}
}
}
base.VisitMethodCall(methodCall);
}
示例4: VisitMethodCall
/// <summary>Visits a constructor invocation.</summary>
/// <param name="cons">Construction.</param>
/// <returns>Resulting expression to visit.</returns>
public override void VisitMethodCall(MethodCall methodCall)
{
if (methodCall != null)
{
MemberBinding callBinding = methodCall.Callee as MemberBinding;
if (callBinding != null)
{
Method method = callBinding.BoundMember as Method;
if (method != null &&
method.DeclaringType.FullName == "Microsoft.OData.Client.EntityDescriptor" &&
method.Name.Name != "get_Entity" &&
method.Name.Name != "get_StreamDescriptors" &&
method.Name.Name != "set_ETag" &&
method.IsPublic &&
method.NodeType == NodeType.Method)
{
if (methodUnderCheck.DeclaringType.FullName == "Microsoft.OData.Client.BaseSaveResult" ||
methodUnderCheck.DeclaringType.FullName == "Microsoft.OData.Client.SaveResult")
{
this.Problems.Add(new Problem(GetResolution(methodUnderCheck.FullName)));
}
}
}
}
base.VisitMethodCall(methodCall);
}
示例5: VisitAssignmentStatement
public override Statement VisitAssignmentStatement(AssignmentStatement assignment)
{
MemberBinding binding = assignment.Target as MemberBinding;
if (binding != null)
{
Expression target = VisitExpression(binding.TargetObject);
Field boundMember = (Field) binding.BoundMember;
Expression source = VisitExpression(assignment.Source);
if (!boundMember.IsStatic && !boundMember.DeclaringType.IsValueType && boundMember.DeclaringType.Contract != null && boundMember.DeclaringType.Contract.FramePropertyGetter != null && boundMember != boundMember.DeclaringType.Contract.FrameField)
{
Local targetLocal = new Local(boundMember.DeclaringType);
Statement evaluateTarget = new AssignmentStatement(targetLocal, target, assignment.SourceContext);
Local sourceLocal = new Local(boundMember.Type);
Statement evaluateSource = new AssignmentStatement(sourceLocal, source, assignment.SourceContext);
Expression guard = new MethodCall(new MemberBinding(targetLocal, boundMember.DeclaringType.Contract.FramePropertyGetter), null, NodeType.Call, SystemTypes.Guard);
Statement check = new ExpressionStatement(new MethodCall(new MemberBinding(guard, SystemTypes.Guard.GetMethod(Identifier.For("CheckIsWriting"))), null, NodeType.Call, SystemTypes.Void));
Statement stfld = new AssignmentStatement(new MemberBinding(targetLocal, boundMember), sourceLocal, assignment.SourceContext);
return new Block(new StatementList(new Statement[] {evaluateTarget, evaluateSource, check, stfld}));
}
else
{
binding.TargetObject = target;
assignment.Source = source;
return assignment;
}
}
else
{
return base.VisitAssignmentStatement(assignment);
}
}
示例6: GetRecentPostsAsync
public async Task<List<PostInfo>> GetRecentPostsAsync(int numposts)
{
Service service = new Service(this.BlogConnectionInfo.MetaWeblogURL);
MethodCall methodCall = new MethodCall("metaWeblog.getRecentPosts");
methodCall.Parameters.Add(this.BlogConnectionInfo.BlogID);
methodCall.Parameters.Add(this.BlogConnectionInfo.Username);
methodCall.Parameters.Add(this.BlogConnectionInfo.Password);
methodCall.Parameters.Add(numposts);
service.Cookies = this.BlogConnectionInfo.Cookies;
MethodResponse methodResponse = await service.ExecuteAsync(methodCall);
Value value = methodResponse.Parameters[0];
XmlRPC.Array array = (XmlRPC.Array)value;
List<PostInfo> list = new List<PostInfo>();
foreach (Value current in array)
{
Struct @struct = (Struct)current;
list.Add(new PostInfo
{
Title = @struct.Get<StringValue>("title", StringValue.NullString).String,
DateCreated = new DateTime?(@struct.Get<DateTimeValue>("dateCreated").Data),
Link = @struct.Get<StringValue>("link", StringValue.NullString).String,
PostID = @struct.Get<StringValue>("postid", StringValue.NullString).String,
UserID = @struct.Get<StringValue>("userid", StringValue.NullString).String,
CommentCount = @struct.Get<IntegerValue>("commentCount", 0).Integer,
PostStatus = @struct.Get<StringValue>("post_status", StringValue.NullString).String,
PermaLink = @struct.Get<StringValue>("permaLink", StringValue.NullString).String,
Description = @struct.Get<StringValue>("description", StringValue.NullString).String
});
}
return list;
}
示例7: VisitMethodCall
protected override Expression VisitMethodCall(MethodCallExpression node)
{
Expression retExpr = null;
if (node.Method.Name == _functionName)
{
var str = node.ToString();
MethodCall call;
if (_methodCalls.TryGetValue(str, out call))
{
++call.CallCount;
}
else
{
call = new MethodCall(node, Expression.Parameter(node.Type, "param" + (_methodCalls.Count)));
_methodCalls.Add(str, call);
}
retExpr = call.Parameter;
}
else
retExpr = base.VisitMethodCall(node);
return retExpr;
}
示例8: QualifyParameters
private static bool QualifyParameters(MethodCall methodCall)
{
if (methodCall.ArgumentsCount < 1)
return true;
var doubleQuotesExpression = methodCall.Arguments[0] as PrimitiveExpression;
if (doubleQuotesExpression != null
&& doubleQuotesExpression.PrimitiveType == PrimitiveType.String
&& (doubleQuotesExpression.Name == "\"\"" || doubleQuotesExpression.Name == "@\"\""))
return true;
var nullExpression = methodCall.Arguments[0] as PrimitiveExpression;
if (nullExpression != null
&& nullExpression.PrimitiveType == PrimitiveType.Void
&& nullExpression.Name == "null")
return true;
var stringEmptyExpression = methodCall.Arguments[0] as ElementReferenceExpression;
if (stringEmptyExpression != null
&& stringEmptyExpression.Name == "Empty"
&& stringEmptyExpression.Qualifier != null
&& stringEmptyExpression.Qualifier.Name.ToLowerInvariant() == "string")
return true;
return false;
}
示例9: VisitMethodCall
/// <summary>Visits a constructor invocation.</summary>
/// <param name="cons">Construction.</param>
/// <returns>Resulting expression to visit.</returns>
public override void VisitMethodCall(MethodCall methodCall)
{
if (methodCall != null)
{
MemberBinding callBinding = methodCall.Callee as MemberBinding;
if (callBinding != null)
{
Method method = callBinding.BoundMember as Method;
if (method != null &&
method.DeclaringType.DeclaringModule.ContainingAssembly.Name == "Microsoft.Spatial" &&
method.DeclaringType.FullName == "Microsoft.Spatial.SpatialImplementation" &&
method.Name.Name == "get_Operations" &&
method.IsPublic &&
method.NodeType == NodeType.Method)
{
if (methodUnderCheck.Name.Name != "VerifyAndGetNonNullOperations")
{
this.Problems.Add(new Problem(GetResolution(methodUnderCheck.FullName)));
}
}
}
}
base.VisitMethodCall(methodCall);
}
示例10: VisitMethodCall
public override void VisitMethodCall(MethodCall call)
{
if (call != null)
{
MemberBinding binding = call.Callee as MemberBinding;
Method calleeMethod = (binding == null) ? null : binding.BoundMember as Method;
if (calleeMethod != null)
{
string fullName = calleeMethod.FullName;
if (exploreGraph && alreadyExplored.Add(fullName))
{
// see if the method(s) is is the call graph
Visit(calleeMethod);
}
int hits;
if (this.timesFound.TryGetValue(fullName, out hits))
{
this.timesFound[fullName] = hits + 1;
}
}
}
base.VisitMethodCall(call);
}
示例11: InterpretedMethod
public InterpretedMethod(string name, string [] parameters,IEvaluable body)
{
this.name=name;
this.parameters=parameters;
this.body=body;
this.delegatedMethodCall = null;
}
示例12: Analyze
public void Analyze(MethodCall methodCall, ISymbolTable context, List<IPreCondition> preConditions)
{
Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall);
ICustomInference matchingRule = MatchingAnalyzeRule (calleeMethod);
if (matchingRule != null)
{
matchingRule.Analyze (methodCall, context, preConditions);
}
}
示例13: VisitMethodCall
public override void VisitMethodCall(MethodCall call) {
Method method = ((MemberBinding)call.Callee).BoundMember as Method;
if ((method != null) &&
(method.DeclaringType.FullName == "System.Script") &&
(method.Name.Name == "Literal")) {
Problems.Add(new Problem(GetResolution(), call.SourceContext));
}
}
示例14: VisitMethodCall
public override Expression VisitMethodCall(MethodCall call)
{
call.Operands = this.VisitExpressionList(call.Operands);
if (call.Callee != null)
{
call.Callee = this.VisitExpression(call.Callee);
}
return call;
}
示例15: InferFragmentType
public Fragment InferFragmentType(MethodCall methodCall, ISymbolTable context)
{
Fragment returnFragment = Fragment.CreateEmpty();
Method calleeMethod = IntrospectionUtility.ExtractMethod (methodCall);
if(_coveredMethods.Contains(calleeMethod.FullName))
{
returnFragment = ParameterFragmentUtility.ParameterFragmentIntersection (methodCall, context);
}
return returnFragment;
}