本文整理汇总了C#中ITypeSymbol.GetAccessibleMembersInThisAndBaseTypes方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeSymbol.GetAccessibleMembersInThisAndBaseTypes方法的具体用法?C# ITypeSymbol.GetAccessibleMembersInThisAndBaseTypes怎么用?C# ITypeSymbol.GetAccessibleMembersInThisAndBaseTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeSymbol
的用法示例。
在下文中一共展示了ITypeSymbol.GetAccessibleMembersInThisAndBaseTypes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCompatibleMethodsInClass
//TODO: check accessibility
public static IEnumerable<IMethodSymbol> GetCompatibleMethodsInClass (ITypeSymbol cls, IMethodSymbol matchMeth)
{
ITypeSymbol[] pars = new ITypeSymbol[matchMeth.Parameters.Length];
List<ITypeSymbol>[] baseTypes = new List<ITypeSymbol>[matchMeth.Parameters.Length];
for (int i = 0; i < matchMeth.Parameters.Length; i++) {
pars[i] = matchMeth.Parameters[i].Type;
baseTypes[i] = new List<ITypeSymbol> (pars[i].GetBaseTypes ());
}
var matchMethType = matchMeth.ReturnType;
foreach (IMethodSymbol method in cls.GetAccessibleMembersInThisAndBaseTypes<IMethodSymbol> (cls)) {
if (method.DeclaredAccessibility == Accessibility.Private || method.Parameters.Length != pars.Length || !method.ReturnType.Equals (matchMethType)
|| method.DeclaredAccessibility == Accessibility.Internal)
continue;
bool allCompatible = true;
//compare each parameter
for (int i = 0; i < pars.Length; i++) {
var pt = method.Parameters[i].Type;
bool parCompatible = pars[i].Equals (pt);
if (!parCompatible && !baseTypes[i].Any (t => t.Equals (pt))) {
allCompatible = false;
break;
}
}
if (allCompatible)
yield return method;
}
}