本文整理汇总了C#中ITypeDefinition.GetNonInterfaceBaseTypes方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.GetNonInterfaceBaseTypes方法的具体用法?C# ITypeDefinition.GetNonInterfaceBaseTypes怎么用?C# ITypeDefinition.GetNonInterfaceBaseTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefinition
的用法示例。
在下文中一共展示了ITypeDefinition.GetNonInterfaceBaseTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseClassIsFormOrControl
public static bool BaseClassIsFormOrControl(ITypeDefinition c)
{
if (c == null)
return false;
// Simple test for fully qualified name
foreach (var baseType in c.GetNonInterfaceBaseTypes()) {
var baseTypeName = baseType.FullName;
if (baseTypeName == "System.Windows.Forms.Form"
|| baseTypeName == "System.Windows.Forms.UserControl")
{
return true;
}
}
return false;
}
示例2: UpdateTestClass
public void UpdateTestClass(ITypeDefinition typeDefinition)
{
fullTypeName = typeDefinition.FullTypeName;
if (this.NestedTestsInitialized) {
int baseClassIndex = 0;
foreach (IType baseType in typeDefinition.GetNonInterfaceBaseTypes()) {
ITypeDefinition baseTypeDef = baseType.GetDefinition();
// Check that the base type isn't equal to System.Object or the current class itself
if (baseTypeDef == null || baseTypeDef == typeDefinition || baseTypeDef.KnownTypeCode == KnownTypeCode.Object)
continue;
if (baseTypeDef.DeclaringTypeDefinition != null)
continue; // we only support inheriting from top-level classes
var baseClassName = baseTypeDef.FullTypeName;
if (baseClassIndex < baseClassNames.Count && baseClassName == baseClassNames[baseClassIndex]) {
// base class is already in the list, just keep it
baseClassIndex++;
} else {
// base class is not in the list, or the remaining portion of the list differs
// remove remaining portion of the list:
RemoveBaseClasses(baseClassIndex);
// Add new base class:
parentProject.RegisterInheritedClass(baseClassName, this);
baseClassNames.Add(baseClassName);
baseClassIndex++;
}
}
HashSet<ITest> newOrUpdatedNestedTests = new HashSet<ITest>();
// Update nested test classes:
foreach (ITypeDefinition nestedClass in typeDefinition.NestedTypes) {
if (!NUnitTestFramework.IsTestClass(nestedClass))
continue;
NUnitTestClass nestedTestClass = FindNestedTestClass(nestedClass.Name, nestedClass.TypeParameterCount);
if (nestedTestClass != null) {
nestedTestClass.UpdateTestClass(nestedClass);
} else {
nestedTestClass = new NUnitTestClass(parentProject, nestedClass.FullTypeName);
this.NestedTestCollection.Add(nestedTestClass);
}
newOrUpdatedNestedTests.Add(nestedTestClass);
}
// Get methods (not operators etc.)
foreach (IMethod method in typeDefinition.GetMethods(m => m.SymbolKind == SymbolKind.Method)) {
if (!NUnitTestFramework.IsTestMethod(method))
continue;
IUnresolvedMethod unresolvedMethod = (IUnresolvedMethod)method.UnresolvedMember;
string methodNameWithDeclaringType;
FullTypeName derivedFixture;
if (method.DeclaringTypeDefinition == typeDefinition) {
derivedFixture = default(FullTypeName); // method is not inherited
methodNameWithDeclaringType = method.Name;
} else {
if (method.DeclaringTypeDefinition == null)
continue;
derivedFixture = fullTypeName; // method is inherited
methodNameWithDeclaringType = method.DeclaringTypeDefinition.Name + "." + method.Name;
}
NUnitTestMethod testMethod;
if (method.IsOverride) {
testMethod = FindTestMethodWithShortName(method.Name);
} else {
testMethod = FindTestMethod(methodNameWithDeclaringType);
}
if (testMethod != null) {
testMethod.UpdateTestMethod(unresolvedMethod, derivedFixture);
} else {
testMethod = new NUnitTestMethod(parentProject, unresolvedMethod, derivedFixture);
this.NestedTestCollection.Add(testMethod);
}
newOrUpdatedNestedTests.Add(testMethod);
}
// Remove all tests that weren't contained in the new type definition anymore:
this.NestedTestCollection.RemoveAll(t => !newOrUpdatedNestedTests.Contains(t));
}
}