本文整理汇总了C#中SimpleType.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleType.AddChild方法的具体用法?C# SimpleType.AddChild怎么用?C# SimpleType.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleType
的用法示例。
在下文中一共展示了SimpleType.AddChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToTypeReference
public static AstType ConvertToTypeReference (this MonoDevelop.Projects.Dom.IReturnType returnType)
{
string primitiveType;
if (TypeTable.TryGetValue (returnType.DecoratedFullName, out primitiveType))
return new PrimitiveType (primitiveType);
AstType result = null;
if (!string.IsNullOrEmpty (returnType.Namespace))
result = new SimpleType (returnType.Namespace);
foreach (var part in returnType.Parts) {
if (result == null) {
var st = new SimpleType (part.Name);
foreach (var type in part.GenericArguments.Select (ga => ConvertToTypeReference (ga)))
st.AddChild (type, SimpleType.Roles.TypeArgument);
result = st;
} else {
var mt = new ICSharpCode.NRefactory.CSharp.MemberType () {
Target = result,
MemberName = part.Name
};
foreach (var type in part.GenericArguments.Select (ga => ConvertToTypeReference (ga)))
mt.AddChild (type, SimpleType.Roles.TypeArgument);
result = mt;
}
}
/*
List<TypeReference> genericTypes = new List<TypeReference> ();
foreach (MonoDevelop.Projects.Dom.IReturnType genericType in returnType.GenericArguments) {
genericTypes.Add (ConvertToTypeReference (genericType));
}
TypeReference result = new AstType (returnType.FullName, genericTypes);
result.IsKeyword = true;
result.PointerNestingLevel = returnType.PointerNestingLevel;
if (returnType.ArrayDimensions > 0) {
int[] rankSpecfier = new int[returnType.ArrayDimensions];
for (int i = 0; i < returnType.ArrayDimensions; i++) {
rankSpecfier[i] = returnType.GetDimension (i);
}
result.RankSpecifier = rankSpecfier;
}*/
return result;
}
示例2: ConvertImport
AstType ConvertImport(MemberName memberName)
{
if (memberName.Left != null) {
// left.name
var t = new MemberType();
// t.IsDoubleColon = memberName.IsDoubleColon;
t.AddChild(ConvertImport(memberName.Left), MemberType.TargetRole);
var loc = LocationsBag.GetLocations(memberName);
if (loc != null)
t.AddChild(new CSharpTokenNode(Convert(loc [0]), Roles.Dot), Roles.Dot);
t.AddChild(Identifier.Create(memberName.Name, Convert(memberName.Location)), Roles.Identifier);
AddTypeArguments(t, memberName);
return t;
} else {
var t = new SimpleType();
t.AddChild(Identifier.Create(memberName.Name, Convert(memberName.Location)), Roles.Identifier);
AddTypeArguments(t, memberName);
return t;
}
}
示例3: ConvertImport
AstType ConvertImport (MemberName memberName)
{
if (memberName.Left != null) {
// left.name
var t = new MemberType();
t.IsDoubleColon = memberName.IsDoubleColon;
t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
if (!memberName.DotLocation.IsNull)
t.AddChild (new CSharpTokenNode (Convert (memberName.DotLocation), 1), MemberType.Roles.Dot);
t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier);
AddTypeArguments (t, memberName.TypeArguments);
return t;
} else {
SimpleType t = new SimpleType();
t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier);
AddTypeArguments (t, memberName.TypeArguments);
return t;
}
}
示例4: UnboundTypeOfExpressionTest
public void UnboundTypeOfExpressionTest()
{
var type = new SimpleType("MyType");
type.AddChild (new SimpleType (), Roles.TypeArgument);
type.AddChild (new SimpleType (), Roles.TypeArgument);
ParseUtilCSharp.AssertExpression(
"typeof(MyType<,>)",
new TypeOfExpression {
Type = type
});
}
示例5: ConvertImport
AstType ConvertImport (MemberName memberName)
{
if (memberName.Left != null) {
// left.name
var t = new MemberType();
t.IsDoubleColon = memberName.IsDoubleColon;
t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier);
AddTypeArguments (t, (List<Location>)null, memberName.TypeArguments);
return t;
} else {
SimpleType t = new SimpleType();
t.AddChild (Identifier.Create (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier);
AddTypeArguments (t, (List<Location>)null, memberName.TypeArguments);
return t;
}
}
示例6: ConvertImport
AstType ConvertImport (MemberName memberName)
{
if (memberName.Left != null) {
// left.name
MemberType t = new MemberType();
t.IsDoubleColon = memberName.IsDoubleColon;
t.AddChild (ConvertImport (memberName.Left), MemberType.TargetRole);
t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), MemberType.Roles.Identifier);
return t;
} else {
SimpleType t = new SimpleType();
t.AddChild (new Identifier (memberName.Name, Convert(memberName.Location)), SimpleType.Roles.Identifier);
// TODO type arguments
return t;
}
}