本文整理汇总了C#中IClass.IsTypeInInheritanceTree方法的典型用法代码示例。如果您正苦于以下问题:C# IClass.IsTypeInInheritanceTree方法的具体用法?C# IClass.IsTypeInInheritanceTree怎么用?C# IClass.IsTypeInInheritanceTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClass
的用法示例。
在下文中一共展示了IClass.IsTypeInInheritanceTree方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseClassIsFormOrControl
public static bool BaseClassIsFormOrControl(IClass c)
{
// Simple test for fully qualified name
c = c.GetCompoundClass();
foreach (IReturnType baseType in c.BaseTypes) {
if (baseType.FullyQualifiedName == "System.Windows.Forms.Form"
|| baseType.FullyQualifiedName == "System.Windows.Forms.UserControl"
// also accept Form and UserControl when they could not be resolved
|| baseType.FullyQualifiedName == "Form"
|| baseType.FullyQualifiedName == "UserControl")
{
return true;
}
}
IClass form = c.ProjectContent.GetClass("System.Windows.Forms.Form", 0);
IClass userControl = c.ProjectContent.GetClass("System.Windows.Forms.UserControl", 0);
if (form != null && c.IsTypeInInheritanceTree(form))
return true;
if (userControl != null && c.IsTypeInInheritanceTree(userControl))
return true;
return false;
}
示例2: IsAccessible
public bool IsAccessible(IClass callingClass, bool isAccessThoughReferenceOfCurrentClass)
{
if (IsPublic) {
return true;
} else if (IsInternal) {
// members can be both internal and protected: in that case, we want to return true if it is visible
// through any of the modifiers
if (callingClass != null && this.DeclaringType.ProjectContent.InternalsVisibleTo(callingClass.ProjectContent))
return true;
}
// protected or private:
// search in callingClass and, if callingClass is a nested class, in its outer classes
while (callingClass != null) {
if (IsProtected) {
if (!isAccessThoughReferenceOfCurrentClass && !IsStatic)
return false;
return callingClass.IsTypeInInheritanceTree(this.DeclaringType);
} else {
// private
if (DeclaringType.FullyQualifiedName == callingClass.FullyQualifiedName
&& DeclaringType.TypeParameters.Count == callingClass.TypeParameters.Count)
{
return true;
}
}
callingClass = callingClass.DeclaringType;
}
return false;
}
示例3: GetAccessibleTypes
public List<IClass> GetAccessibleTypes(IClass callingClass)
{
List<IClass> types = new List<IClass>();
List<IClass> visitedTypes = new List<IClass>();
IClass currentClass = this;
do {
if (visitedTypes.Contains(currentClass))
break;
visitedTypes.Add(currentClass);
bool isClassInInheritanceTree = callingClass != null ? callingClass.IsTypeInInheritanceTree(currentClass) : false;
foreach (IClass c in currentClass.InnerClasses) {
if (c.IsAccessible(callingClass, isClassInInheritanceTree)) {
types.Add(c);
}
}
currentClass = currentClass.BaseClass;
} while (currentClass != null);
return types;
}