本文整理汇总了C#中MethodDefinition.TryGetDeclaringType方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDefinition.TryGetDeclaringType方法的具体用法?C# MethodDefinition.TryGetDeclaringType怎么用?C# MethodDefinition.TryGetDeclaringType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodDefinition
的用法示例。
在下文中一共展示了MethodDefinition.TryGetDeclaringType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAssertMethod
public bool IsAssertMethod(MethodDefinition method, out int usefulParameters)
{
SafeDebug.AssumeNotNull(method, "method");
TypeDefinition type;
if (method.TryGetDeclaringType(out type))
{
if (type.SerializableName == NUnitTestFrameworkMetadata.AssertTypeDefinition)
{
switch (method.ShortName)
{
case "IsEmpty":
case "IsNotEmpty":
case "False":
case "IsFalse":
case "True":
case "IsTrue":
case "IsAssignableFrom":
case "IsNotAssignableFrom":
case "IsNull":
case "IsNotNull":
case "Null":
case "NotNull":
case "IsNotNullOrEmpty":
case "IsNullOrEmpty":
case "IsNan":
case "IsInstanceOf": //not entirely correct
case "IsNotInstanceOf": //not entirely correct
usefulParameters = 1;
return true;
case "AreEqual":
case "AssertDoublesAreEqual":
case "AreNotEqual":
case "Contains":
case "AreSame":
case "AreNotSame":
case "Greater":
case "GreaterOrEqual":
case "Less":
case "LessOrEqual":
usefulParameters = 2;
return true;
}
}
else if (type.SerializableName == NUnitTestFrameworkMetadata.CollectionAssertTypeDefinition)
{
switch (method.ShortName)
{
case "Equals":
case "ReferenceEquals":
usefulParameters = -1;
return false;
default:
usefulParameters = 0;
return true;
}
}
}
usefulParameters = -1;
return false;
}
示例2: IsAssertMethod
public bool IsAssertMethod(MethodDefinition method, out int usefulParameters)
{
SafeDebug.AssumeNotNull(method, "method");
TypeDefinition type;
if (method.TryGetDeclaringType(out type) && type.SerializableName == XunitTestFrameworkMetadata.Type_Assert.Definition)
if (parameterCount.TryGetValue(method.ShortName, out usefulParameters))
return true;
usefulParameters = -1;
return false;
}