6 changed files with 174 additions and 3 deletions
@ -0,0 +1,40 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <author name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Type Reference used when the fully qualified type name is known.
|
||||||
|
/// </summary>
|
||||||
|
public class GetClassTypeReference : AbstractTypeReference |
||||||
|
{ |
||||||
|
string fullTypeName; |
||||||
|
int typeParameterCount; |
||||||
|
|
||||||
|
public GetClassTypeReference(string fullTypeName, int typeParameterCount) |
||||||
|
{ |
||||||
|
if (fullTypeName == null) |
||||||
|
throw new ArgumentNullException("fullTypeName"); |
||||||
|
this.fullTypeName = fullTypeName; |
||||||
|
this.typeParameterCount = typeParameterCount; |
||||||
|
} |
||||||
|
|
||||||
|
public override IType Resolve(ITypeResolveContext context) |
||||||
|
{ |
||||||
|
return context.GetClass(fullTypeName, typeParameterCount, StringComparer.Ordinal); |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
if (typeParameterCount == 0) |
||||||
|
return fullTypeName; |
||||||
|
else |
||||||
|
return fullTypeName + "`" + typeParameterCount; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <author name="Daniel Grunwald"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.NRefactory.TypeSystem.Implementation |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Type reference used to reference nested types.
|
||||||
|
/// </summary>
|
||||||
|
public class NestedTypeReference : AbstractTypeReference |
||||||
|
{ |
||||||
|
ITypeReference baseTypeRef; string name; int typeParameterCount; |
||||||
|
|
||||||
|
public NestedTypeReference(ITypeReference baseTypeRef, string name, int typeParameterCount) |
||||||
|
{ |
||||||
|
if (baseTypeRef == null) |
||||||
|
throw new ArgumentNullException("baseTypeRef"); |
||||||
|
if (name == null) |
||||||
|
throw new ArgumentNullException("name"); |
||||||
|
this.baseTypeRef = baseTypeRef; |
||||||
|
this.name = name; |
||||||
|
this.typeParameterCount = typeParameterCount; |
||||||
|
} |
||||||
|
|
||||||
|
public override IType Resolve(ITypeResolveContext context) |
||||||
|
{ |
||||||
|
foreach (IType type in baseTypeRef.GetNestedTypes(context)) { |
||||||
|
if (type.Name == name && type.TypeParameterCount == typeParameterCount) |
||||||
|
return type; |
||||||
|
} |
||||||
|
return SharedTypes.UnknownType; |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
if (typeParameterCount == 0) |
||||||
|
return baseTypeRef + "+" + name; |
||||||
|
else |
||||||
|
return baseTypeRef + "+" + name + "`" + typeParameterCount; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue