本文整理汇总了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;
}
}
示例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;
}
示例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);
}
}
示例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);
}
}