本文整理汇总了C#中Internal.TypeSystem.TypeDesc.GetMethods方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDesc.GetMethods方法的具体用法?C# TypeDesc.GetMethods怎么用?C# TypeDesc.GetMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Internal.TypeSystem.TypeDesc
的用法示例。
在下文中一共展示了TypeDesc.GetMethods方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RootMethods
private void RootMethods(TypeDesc type, string reason, IRootingServiceProvider rootProvider)
{
foreach (MethodDesc method in type.GetMethods())
{
// Skip methods with no IL and uninstantiated generic methods
if (method.IsIntrinsic || method.IsAbstract || method.HasInstantiation)
continue;
if (method.IsInternalCall)
continue;
try
{
CheckCanGenerateMethod(method);
rootProvider.AddCompilationRoot(method, reason);
}
catch (TypeSystemException)
{
// TODO: fail compilation if a switch was passed
// Individual methods can fail to load types referenced in their signatures.
// Skip them in library mode since they're not going to be callable.
continue;
// TODO: Log as a warning
}
}
}
示例2: ComputeAllVirtualMethods
public override IEnumerable<MethodDesc> ComputeAllVirtualMethods(TypeDesc type)
{
foreach (var method in type.GetMethods())
{
if (method.IsVirtual)
yield return method;
}
}
示例3: RootMethods
private void RootMethods(TypeDesc type, string reason, IRootingServiceProvider rootProvider)
{
foreach (MethodDesc method in type.GetMethods())
{
// Skip methods with no IL and uninstantiated generic methods
if (method.IsIntrinsic || method.IsAbstract || method.ContainsGenericVariables)
continue;
if (method.IsInternalCall)
continue;
rootProvider.AddCompilationRoot(method, reason);
}
}
示例4: TryGetMethodFromInterfaceSlot
/// <summary>
/// Get the MethodDesc that corresponds to an interface type/slot pair
/// </summary>
public static bool TryGetMethodFromInterfaceSlot(TypeDesc owningType, ushort slot, out MethodDesc method)
{
int iMethod = -1;
method = null;
// This is only valid to call on an interface
if (!owningType.IsInterface)
return false;
// Slots on generic interface types are off by one.
if (owningType.IsGeneric())
{
if (slot == 0)
throw new BadImageFormatException();
slot--;
}
foreach (MethodDesc searchMethod in owningType.GetMethods())
{
if (searchMethod.IsVirtual)
{
iMethod++;
if (iMethod == slot)
{
method = searchMethod;
return true;
}
}
}
return false;
}