本文整理汇总了C#中IMethod.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# IMethod.Equals方法的具体用法?C# IMethod.Equals怎么用?C# IMethod.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethod
的用法示例。
在下文中一共展示了IMethod.Equals方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMethodSemantics
private MethodScriptSemantics GetMethodSemantics(IMethod m) {
if (m.IsAccessor) {
var prop = m.AccessorOwner as IProperty;
if (prop != null) {
var psem = _metadataImporter.GetPropertySemantics(prop);
if (psem.Type != PropertyScriptSemantics.ImplType.GetAndSetMethods)
throw new InvalidOperationException("Property " + prop.Name + " should be implemented with get/set methods");
if (m.Equals(prop.Getter))
return psem.GetMethod;
else if (m.Equals(prop.Setter))
return psem.SetMethod;
else
throw new Exception(m + " is neither the getter nor the setter for " + prop);
}
var evt = m.AccessorOwner as IEvent;
if (evt != null) {
var esem = _metadataImporter.GetEventSemantics(evt);
if (esem.Type != EventScriptSemantics.ImplType.AddAndRemoveMethods)
throw new InvalidOperationException("Event " + prop.Name + " should be implemented with add/remove methods");
if (m.Equals(evt.AddAccessor))
return esem.AddMethod;
else if (m.Equals(evt.RemoveAccessor))
return esem.RemoveMethod;
else
throw new Exception(m + " is neither the adder nor the remover for " + evt);
}
throw new ArgumentException("Invalid accessor owner " + m.AccessorOwner + " on member " + m);
}
else
return _metadataImporter.GetMethodSemantics(m);
}
示例2: IsMethodInvoked
public static bool IsMethodInvoked(IInvocationExpression invocationExpression, IMethod method)
{
var calledMethod = invocationExpression.InvocationExpressionReference.Resolve().Result.DeclaredElement as IMethod;
return method.Equals(calledMethod);
}