本文整理汇总了C#中Mono.Cecil.MethodReference.MatchMethodOnly方法的典型用法代码示例。如果您正苦于以下问题:C# MethodReference.MatchMethodOnly方法的具体用法?C# MethodReference.MatchMethodOnly怎么用?C# MethodReference.MatchMethodOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.MethodReference
的用法示例。
在下文中一共展示了MethodReference.MatchMethodOnly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoesMatchMethod
private static bool DoesMatchMethod(MethodReference mInternal, MethodReference m) {
var mInternalDef = mInternal.Resolve();
if (mInternalDef.GetCustomAttribute<JsRedirectAttribute>() != null) {
// Can never return a redirected method
return false;
}
// Look for methods with custom signatures
var detailsAttr = mInternalDef.GetCustomAttribute<JsDetailAttribute>(true);
if (detailsAttr != null) {
var signature = detailsAttr.Properties.FirstOrDefault(x => x.Name == "Signature");
if (signature.Name != null) {
if (mInternal.Name != m.Name) {
return false;
}
var sigTypes = ((CustomAttributeArgument[])signature.Argument.Value)
.Select(x => ((TypeReference)x.Value).FullResolve(m))
.ToArray();
var mReturnType = m.ReturnType.FullResolve(m);
if (!mReturnType.IsSame(sigTypes[0])) {
return false;
}
for (int i = 0; i < m.Parameters.Count; i++) {
var mParameterType = m.Parameters[i].ParameterType.FullResolve(m);
if (!mParameterType.IsSame(sigTypes[i + 1])) {
return false;
}
}
return true;
}
}
// Look for C# method that matches with custom 'this'
Func<bool> isFakeThis = () => {
if (mInternal.HasThis) {
return false;
}
if (mInternal.Name != m.Name) {
return false;
}
if (mInternal.Parameters.Count != m.Parameters.Count + 1) {
return false;
}
if (mInternal.Parameters[0].GetCustomAttribute<JsFakeThisAttribute>() == null) {
return false;
}
if (!mInternal.ReturnType.IsSame(m.ReturnType)) {
return false;
}
for (int i = 1; i < mInternal.Parameters.Count; i++) {
if (!mInternal.Parameters[i].ParameterType.IsSame(m.Parameters[i - 1].ParameterType)) {
return false;
}
}
return true;
};
if (isFakeThis()) {
return true;
}
// Look for C# method that match signature
return mInternal.MatchMethodOnly(m);
}