本文整理汇总了C#中Mono.Cecil.TypeReference.GetMethods方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.GetMethods方法的具体用法?C# TypeReference.GetMethods怎么用?C# TypeReference.GetMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeReference
的用法示例。
在下文中一共展示了TypeReference.GetMethods方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareMethodAgainstTypeMethods
internal void CompareMethodAgainstTypeMethods (MethodDefinition current, TypeReference targetType)
{
if (CheckedTypes.Contains (targetType.Name))
return;
foreach (MethodDefinition target in targetType.GetMethods ()) {
if (target.IsGeneratedCode ())
continue;
Pattern duplicated = GetDuplicatedCode (current, target);
if (duplicated != null && duplicated.Count > 0)
rule.Runner.Report (current, duplicated[0], Severity.High, Confidence.Normal, String.Format ("Duplicated code with {0}", target));
}
}
示例2: DoesTypeStealthilyImplementInterface
private static bool DoesTypeStealthilyImplementInterface (TypeDefinition type, TypeReference iface)
{
//ignore already uninteresting types below (self, enum, struct, static class)
if (type == iface || type.IsEnum || type.IsValueType || type.IsStatic ())
return false;
//if type has less methods than the interface no need to check further
if (!type.HasMethods)
return false;
IList<MethodDefinition> mdc = iface.GetMethods ().ToList ();
if (type.Methods.Count < mdc.Count)
return false;
//type already publicly says it implements the interface
if (type.Implements (iface.FullName))
return false;
foreach (MethodDefinition m in mdc) {
//if any candidate fails we can return right away
//since the interface will never be fully implemented
MethodDefinition candidate = type.GetMethod (MethodAttributes.Public, m.Name);
if (null == candidate || !candidate.IsPublic || candidate.IsStatic)
return false;
//ok interesting candidate! let's check if it matches the signature
if (!AreSameElementTypes (m.ReturnType, candidate.ReturnType))
return false;
if (!CompareParameters (m, candidate))
return false;
}
return true;
}
示例3: OnlyContainsExternalMethods
private static bool OnlyContainsExternalMethods (TypeReference type)
{
bool has_methods = false;
foreach (MethodDefinition method in type.GetMethods ()) {
has_methods = true;
if (!method.IsPInvokeImpl)
return false;
}
// all methods are p/invoke
return has_methods;
}
示例4: GetSmallestOverloaded
//TODO: Perhaps we can perform this action with linq instead of
//loop + hashtable
private static IEnumerable<MethodDefinition> GetSmallestOverloaded (TypeReference type)
{
IDictionary<string, MethodDefinition> possibleOverloaded = new Dictionary<string, MethodDefinition> ();
foreach (MethodDefinition method in type.GetMethods ()) {
if (method.IsPInvokeImpl)
continue;
string name = method.Name;
if (!possibleOverloaded.ContainsKey (name))
possibleOverloaded.Add (name, method);
else {
MethodDefinition candidate = possibleOverloaded [name];
int ccount = candidate.HasParameters ? candidate.Parameters.Count : 0;
int mcount = method.HasParameters ? method.Parameters.Count : 0;
if (ccount > mcount)
possibleOverloaded [name] = method;
}
}
return possibleOverloaded.Values;
}