本文整理汇总了C#中TypeSpec.AddArray方法的典型用法代码示例。如果您正苦于以下问题:C# TypeSpec.AddArray方法的具体用法?C# TypeSpec.AddArray怎么用?C# TypeSpec.AddArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSpec
的用法示例。
在下文中一共展示了TypeSpec.AddArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
//.........这里部分代码省略.........
case '*':
if (data.is_byref)
throw new ArgumentException("Can't have a pointer to a byref type", "typeName");
++data.pointer_level;
break;
case ',':
if (is_recurse)
{
int end = pos;
while (end < typeName.Length && typeName[end] != ']')
++end;
if (end >= typeName.Length)
throw new ArgumentException("Unmatched ']' while parsing generic argument assembly name");
data.assembly_name = typeName.Substring(pos + 1, end - pos - 1).Trim();
p = end + 1;
return data;
}
data.assembly_name = typeName.Substring(pos + 1).Trim();
pos = typeName.Length;
break;
case '[':
if (data.is_byref)
throw new ArgumentException("Byref qualifier must be the last one of a type", "typeName");
++pos;
if (pos >= typeName.Length)
throw new ArgumentException("Invalid array/generic spec", "typeName");
SkipSpace(typeName, ref pos);
if (typeName[pos] != ',' && typeName[pos] != '*' && typeName[pos] != ']')
{//generic args
List<TypeSpec> args = new List<TypeSpec>();
if (data.IsArray)
throw new ArgumentException("generic args after array spec", "typeName");
while (pos < typeName.Length)
{
SkipSpace(typeName, ref pos);
bool aqn = typeName[pos] == '[';
if (aqn)
++pos; //skip '[' to the start of the type
args.Add(Parse(typeName, ref pos, true, aqn));
if (pos >= typeName.Length)
throw new ArgumentException("Invalid generic arguments spec", "typeName");
if (typeName[pos] == ']')
break;
if (typeName[pos] == ',')
++pos; // skip ',' to the start of the next arg
else
throw new ArgumentException(string.Format("Invalid generic arguments separator '{0}'", typeName[pos]), "typeName");
}
if (pos >= typeName.Length || typeName[pos] != ']')
throw new ArgumentException("Error parsing generic params spec", "typeName");
data.generic_params = args;
}
else
{ //array spec
int dimensions = 1;
bool bound = false;
while (pos < typeName.Length && typeName[pos] != ']')
{
if (typeName[pos] == '*')
{
if (bound)
throw new ArgumentException("Array spec cannot have 2 bound dimensions", "typeName");
bound = true;
}
else if (typeName[pos] != ',')
throw new ArgumentException(string.Format("Invalid character in array spec '{0}'", typeName[pos]), "typeName");
else
++dimensions;
++pos;
SkipSpace(typeName, ref pos);
}
if (typeName[pos] != ']')
throw new ArgumentException("Error parsing array spec", "typeName");
if (dimensions > 1 && bound)
throw new ArgumentException("Invalid array spec, multi-dimensional array cannot be bound", "typeName");
data.AddArray(new ArraySpec(dimensions, bound));
}
break;
case ']':
if (is_recurse)
{
p = pos + 1;
return data;
}
throw new ArgumentException("Unmatched ']'", "typeName");
default:
throw new ArgumentException(string.Format("Bad type def, can't handle '{0}' at {1}", typeName[pos], pos), "typeName");
}
}
}
p = pos;
return data;
}