当前位置: 首页>>代码示例>>C#>>正文


C# ITypeDefinition.GetNonInterfaceBaseTypes方法代码示例

本文整理汇总了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;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:15,代码来源:SecondaryDisplayBinding.cs

示例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));
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:78,代码来源:NUnitTestClass.cs


注:本文中的ITypeDefinition.GetNonInterfaceBaseTypes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。