本文整理汇总了C#中ICSharpCode.NRefactory.TypeSystem.ParameterizedType.GetNestedTypes方法的典型用法代码示例。如果您正苦于以下问题:C# ParameterizedType.GetNestedTypes方法的具体用法?C# ParameterizedType.GetNestedTypes怎么用?C# ParameterizedType.GetNestedTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.NRefactory.TypeSystem.ParameterizedType
的用法示例。
在下文中一共展示了ParameterizedType.GetNestedTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGenericNestedTypeOfBoundGenericClass
public void GetGenericNestedTypeOfBoundGenericClass()
{
// class A<X> { class B<Y> { } }
DefaultUnresolvedTypeDefinition a = new DefaultUnresolvedTypeDefinition(string.Empty, "A");
a.TypeParameters.Add(new DefaultUnresolvedTypeParameter(SymbolKind.TypeDefinition, 0, "X"));
DefaultUnresolvedTypeDefinition b = new DefaultUnresolvedTypeDefinition(a, "B");
b.TypeParameters.Add(a.TypeParameters[0]);
b.TypeParameters.Add(new DefaultUnresolvedTypeParameter(SymbolKind.TypeDefinition, 1, "Y"));
a.NestedTypes.Add(b);
var compilation = TypeSystemHelper.CreateCompilation(a, b);
ITypeDefinition resolvedA = compilation.MainAssembly.GetTypeDefinition(a.FullTypeName);
ITypeDefinition resolvedB = compilation.MainAssembly.GetTypeDefinition(b.FullTypeName);
// A<> gets self-parameterized, B<> stays unbound
Assert.AreEqual("A`1+B`1[[`0],[]]", resolvedA.GetNestedTypes().Single().ReflectionName);
ParameterizedType pt = new ParameterizedType(resolvedA, new [] { compilation.FindType(KnownTypeCode.String) });
Assert.AreEqual("A`1+B`1[[System.String],[]]", pt.GetNestedTypes().Single().ReflectionName);
}
示例2: GetGenericNestedTypeOfBoundGenericClass
public void GetGenericNestedTypeOfBoundGenericClass()
{
// class A<X> { class B<Y> { } }
DefaultTypeDefinition a = new DefaultTypeDefinition(mscorlib, string.Empty, "A");
a.TypeParameters.Add(new DefaultTypeParameter(EntityType.TypeDefinition, 0, "X"));
DefaultTypeDefinition b = new DefaultTypeDefinition(a, "B");
b.TypeParameters.Add(a.TypeParameters[0]);
b.TypeParameters.Add(new DefaultTypeParameter(EntityType.TypeDefinition, 1, "Y"));
a.NestedTypes.Add(b);
// A<> gets self-parameterized, B<> stays unbound
Assert.AreEqual("A`1+B`1[[`0],[]]", a.GetNestedTypes(mscorlib).Single().ReflectionName);
ParameterizedType pt = new ParameterizedType(a, new [] { KnownTypeReference.String.Resolve(mscorlib) });
Assert.AreEqual("A`1+B`1[[System.String],[]]", pt.GetNestedTypes(mscorlib).Single().ReflectionName);
}