本文整理汇总了C#中TypeNode.GetNestedType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.GetNestedType方法的具体用法?C# TypeNode.GetNestedType怎么用?C# TypeNode.GetNestedType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeNode
的用法示例。
在下文中一共展示了TypeNode.GetNestedType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PTypeRef
void PTypeRef(out TypeNode tn) {
Module assem = null;
string ns, tname, nestedname;
ArrayList/*<string>*/ typeNames;
TypeNodeList templateArgs = null;
if (la.kind == 28) {
Assembly(out assem);
}
QualName(out ns, out tname);
NestedTypeName(out typeNames, out nestedname);
if (la.kind == 31) {
Get();
TypeNode arg;
PType(out arg);
templateArgs = new TypeNodeList(); templateArgs.Add(arg);
while (la.kind == 23) {
Get();
PType(out arg);
templateArgs.Add(arg);
}
Expect(32);
}
if ( assem == null ){
assem = currentAssembly;
}
#if !WHIDBEY
if (templateArgs != null){
/* then need to create the pseudo-generic name */
string pseudoGenericName = tname;
/*pseudoGenericName += SystemTypes.GenericTypeNamesMangleChar;*/
/*pseudoGenericName += templateArgs.Count.ToString();*/
pseudoGenericName += "<";
for (int i = 0, n = templateArgs.Count; i < n; i++){
if (i > 0)
pseudoGenericName += ",";
pseudoGenericName += templateArgs[i].FullName;
}
pseudoGenericName += ">";
tname = pseudoGenericName;
}
#endif
tn = assem.GetType(Identifier.For(ns),Identifier.For(tname));
if (tn == null) {
this.errors.SemErr(t.filename, t.line, t.col,
String.Format("could not resolve namespace {0}, type {1}", ns, tname));
throw new Exception("cannot continue"); //Errors.Exception("cannot continue");
}
// now do nested types
for (int i=0; i<typeNames.Count; i++){
tn = tn.GetNestedType(Identifier.For((string)typeNames[i]));
}
if (tn == null) {
this.errors.SemErr(t.filename, t.line, t.col,
String.Format("could not resolve namespace {0} type {1} nesting {2}", ns, tname, nestedname));
throw new Exception("cannot continue"); //Errors.Exception("cannot continue");
}
#if WHIDBEY
/* Pre-Whidbey, templateArgs are used to construct a pseudo-generic name */
if (templateArgs != null)
{
tn = tn.GetTemplateInstance(assem, null, null, templateArgs);
}
#endif
}
示例2: GetTypeFromSerializedName
private TypeNode/*!*/ GetTypeFromSerializedName(string/*!*/ typeName, TypeNode/*!*/ nestingType)
{
string/*!*/ name;
int i = 0;
ParseSimpleTypeName(typeName, out name, ref i);
TypeNode t = nestingType.GetNestedType(Identifier.For(name));
if (t == null)
t = this.GetDummyTypeNode(Identifier.Empty, Identifier.For(name), nestingType.DeclaringModule, nestingType, false);
if (i >= typeName.Length) return t;
char ch = typeName[i];
if (ch == '+') return this.GetTypeFromSerializedName(typeName.Substring(i + 1), t);
if (ch == '&') return t.GetReferenceType();
if (ch == '*') return t.GetPointerType();
if (ch == '[') return this.ParseArrayOrGenericType(typeName.Substring(i + 1, typeName.Length - 1 - i), t);
throw new InvalidMetadataException(ExceptionStrings.BadSerializedTypeName);
}