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


C# ITypeDefinition.GetDefinition方法代码示例

本文整理汇总了C#中ITypeDefinition.GetDefinition方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.GetDefinition方法的具体用法?C# ITypeDefinition.GetDefinition怎么用?C# ITypeDefinition.GetDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITypeDefinition的用法示例。


在下文中一共展示了ITypeDefinition.GetDefinition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CollectTypeRelatedMembers

		static IEnumerable<ISymbol> CollectTypeRelatedMembers (ITypeDefinition type)
		{
			yield return type;
			foreach (var c in type.GetDefinition ().GetMembers (m => !m.IsSynthetic && (m.SymbolKind == SymbolKind.Constructor || m.SymbolKind == SymbolKind.Destructor), GetMemberOptions.IgnoreInheritedMembers)) {
				yield return c;
			}
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:7,代码来源:SymbolCollector.cs

示例2: FindDerivedTypes

		/// <summary>
		/// Finds all types that are derived from the given base type.
		/// </summary>
		public static IList<ITypeDefinition> FindDerivedTypes(ITypeDefinition baseType, bool directDerivationOnly)
		{
			if (baseType == null)
				throw new ArgumentNullException("baseType");
			baseType = baseType.GetDefinition(); // ensure we use the compound class
			
			List<ITypeDefinition> results = new List<ITypeDefinition>();
			
			var solutionSnapshot = GetSolutionSnapshot(baseType.Compilation);
			foreach (IProject project in GetProjectsThatCouldReferenceEntity(baseType)) {
				var compilation = solutionSnapshot.GetCompilation(project);
				var importedBaseType = compilation.Import(baseType);
				if (importedBaseType == null)
					continue;
				foreach (ITypeDefinition typeDef in compilation.MainAssembly.GetAllTypeDefinitions()) {
					bool isDerived;
					if (directDerivationOnly) {
						isDerived = typeDef.DirectBaseTypes.Select(t => t.GetDefinition()).Contains(importedBaseType);
					} else {
						isDerived = typeDef.IsDerivedFrom(importedBaseType);
					}
					if (isDerived)
						results.Add(typeDef);
				}
			}
			return results;
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:30,代码来源:FindReferenceService.cs

示例3: RemoveType

		void RemoveType(ITypeDefinition typeDefinition)
		{
			var compoundTypeDef = typeDefinition.GetDefinition() as CompoundTypeDefinition;
			if (compoundTypeDef != null) {
				// Remove one part from a compound class
				var newParts = new List<ITypeDefinition>(compoundTypeDef.GetParts());
				// We cannot use newParts.Remove() because we need to use reference equality
				for (int i = 0; i < newParts.Count; i++) {
					if (newParts[i] == typeDefinition) {
						newParts.RemoveAt(i);
						((DefaultTypeDefinition)typeDefinition).SetCompoundTypeDefinition(typeDefinition);
						break;
					}
				}
				types.UpdateType(CompoundTypeDefinition.Create(newParts));
			} else {
				types.RemoveType(typeDefinition);
			}
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:19,代码来源:SimpleProjectContent.cs

示例4: RemoveType

		void RemoveType(ITypeDefinition typeDefinition)
		{
			var compoundTypeDef = typeDefinition.GetDefinition() as CompoundTypeDefinition;
			if (compoundTypeDef != null) {
				// Remove one part from a compound class
				var newParts = new List<ITypeDefinition>(compoundTypeDef.GetParts());
				if (newParts.Remove(typeDefinition)) {
					((DefaultTypeDefinition)typeDefinition).SetCompoundTypeDefinition(typeDefinition);
				}
				types.UpdateType(CompoundTypeDefinition.Create(newParts));
			} else {
				types.RemoveType(typeDefinition);
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:14,代码来源:SimpleProjectContent.cs


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