本文整理汇总了C#中Mono.Cecil.TypeReference.EnumResolvedMethods方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.EnumResolvedMethods方法的具体用法?C# TypeReference.EnumResolvedMethods怎么用?C# TypeReference.EnumResolvedMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeReference
的用法示例。
在下文中一共展示了TypeReference.EnumResolvedMethods方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindJsMember
private static MethodReference FindJsMember(MethodReference mRef, TypeReference mappedTRef) {
Func<IEnumerable<CustomAttribute>, string, bool> isMatch = (attrs, mName) => {
return attrs.Any(a => {
string aMethodName = null;
TypeReference aReturnType = null;
IEnumerable<TypeReference> aParameterTypes = null;
bool? isStatic = null;
var numArgs = a.ConstructorArguments.Count;
var ctorArgs = a.ConstructorArguments;
if (numArgs == 0 || (numArgs == 1 && ctorArgs[0].Type.IsString())) {
// Do nothing
} else if (numArgs == 2) {
aReturnType = (TypeReference)ctorArgs[0].Value;
aParameterTypes = ((IEnumerable<CustomAttributeArgument>)ctorArgs[1].Value).Select(x => (TypeReference)x.Value).ToArray();
} else if (numArgs == 3) {
aMethodName = (string)ctorArgs[0].Value;
aReturnType = (TypeReference)ctorArgs[1].Value;
aParameterTypes = ((IEnumerable<CustomAttributeArgument>)ctorArgs[2].Value).Select(x => (TypeReference)x.Value).ToArray();
} else {
throw new InvalidOperationException("Unrecognised JsAttribute constructor");
}
if (isStatic != null) {
if (isStatic.Value == mRef.HasThis) {
return false;
}
}
if (aMethodName == null && aParameterTypes == null && mName == mRef.Name) {
return true;
}
if ((aMethodName ?? mName) != mRef.Name) {
return false;
}
if (aParameterTypes.Count() != mRef.Parameters.Count) {
return false;
}
if (aParameterTypes.Zip(mRef.Parameters, (x, y) => new { aType = x, mRefType = y.ParameterType }).Any(x => {
var aTypeResolved = x.aType.FullResolve(mRef);
var mRefTypeResolved = x.mRefType.FullResolve(mRef);
return !aTypeResolved.IsSame(mRefTypeResolved);
})) {
return false;
}
var aReturnTypeResolved = aReturnType.FullResolve(mRef);
var mRefReturnTypeResolved = mRef.ReturnType.FullResolve(mRef);
if (!aReturnTypeResolved.IsSame(mRefReturnTypeResolved)) {
return false;
}
return true;
});
};
var members = mappedTRef.EnumResolvedMethods(mRef);
var member = members.FirstOrDefault(m => {
var mr = m.Resolve();
var attrs = mr.GetCustomAttributes<JsAttribute>();
var match = isMatch(attrs, m.Name);
return match;
});
return member;
}