本文整理汇总了C#中TypeParameterDeclaration.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# TypeParameterDeclaration.AddChild方法的具体用法?C# TypeParameterDeclaration.AddChild怎么用?C# TypeParameterDeclaration.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeParameterDeclaration
的用法示例。
在下文中一共展示了TypeParameterDeclaration.AddChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTypeParameters
void AddTypeParameters(AstNode parent, MemberName memberName)
{
if (memberName == null || memberName.TypeParameters == null)
return;
var chevronLocs = LocationsBag.GetLocations(memberName.TypeParameters);
if (chevronLocs != null)
parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [chevronLocs.Count - 2]), Roles.LChevron), Roles.LChevron);
for (int i = 0; i < memberName.TypeParameters.Count; i++) {
if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count)
parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [i - 1]), Roles.Comma), Roles.Comma);
var arg = memberName.TypeParameters [i];
if (arg == null)
continue;
var tp = new TypeParameterDeclaration();
List<Location> varianceLocation;
switch (arg.Variance) {
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
varianceLocation = LocationsBag.GetLocations(arg);
if (varianceLocation != null)
tp.AddChild(new CSharpTokenNode(Convert(varianceLocation [0]), TypeParameterDeclaration.InVarianceKeywordRole), TypeParameterDeclaration.InVarianceKeywordRole);
break;
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
varianceLocation = LocationsBag.GetLocations(arg);
if (varianceLocation != null)
tp.AddChild(new CSharpTokenNode(Convert(varianceLocation [0]), TypeParameterDeclaration.OutVarianceKeywordRole), TypeParameterDeclaration.OutVarianceKeywordRole);
break;
default:
tp.Variance = VarianceModifier.Invariant;
break;
}
AddAttributeSection(tp, arg.OptAttributes);
switch (arg.Variance) {
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
break;
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
break;
}
tp.AddChild(Identifier.Create(arg.Name, Convert(arg.Location)), Roles.Identifier);
parent.AddChild(tp, Roles.TypeParameter);
}
if (chevronLocs != null)
parent.AddChild(new CSharpTokenNode(Convert(chevronLocs [chevronLocs.Count - 1]), Roles.RChevron), Roles.RChevron);
}
示例2: AddTypeParameters
void AddTypeParameters (AstNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments)
{
if (typeArguments == null || typeArguments.IsEmpty)
return;
for (int i = 0; i < typeArguments.Count; i++) {
if (location != null && i > 0 && i - 1 < location.Count)
parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma);
var arg = (TypeParameterName)typeArguments.Args[i];
if (arg == null)
continue;
TypeParameterDeclaration tp = new TypeParameterDeclaration();
// TODO: attributes
switch (arg.Variance) {
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
break;
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
break;
}
tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier);
parent.AddChild (tp, InvocationExpression.Roles.TypeParameter);
}
}
示例3: AddTypeParameters
void AddTypeParameters (AstNode parent, Mono.CSharp.TypeArguments typeArguments)
{
if (typeArguments == null || typeArguments.IsEmpty)
return;
var chevronLocs = LocationsBag.GetLocations (typeArguments);
if (chevronLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 2]), 1), InvocationExpression.Roles.LChevron);
for (int i = 0; i < typeArguments.Count; i++) {
if (chevronLocs != null && i > 0 && i - 1 < chevronLocs.Count)
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[i - 1]), 1), InvocationExpression.Roles.Comma);
var arg = (TypeParameterName)typeArguments.Args[i];
if (arg == null)
continue;
TypeParameterDeclaration tp = new TypeParameterDeclaration();
List<Location> varianceLocation;
switch (arg.Variance) {
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
varianceLocation = LocationsBag.GetLocations (arg);
if (varianceLocation != null)
tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole);
break;
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
varianceLocation = LocationsBag.GetLocations (arg);
if (varianceLocation != null)
tp.AddChild (new CSharpTokenNode (Convert (varianceLocation[0]), "out".Length), TypeParameterDeclaration.VarianceRole);
break;
default:
tp.Variance = VarianceModifier.Invariant;
break;
}
AddAttributeSection (tp, arg.OptAttributes);
switch (arg.Variance) {
case Variance.Covariant:
tp.Variance = VarianceModifier.Covariant;
break;
case Variance.Contravariant:
tp.Variance = VarianceModifier.Contravariant;
break;
}
tp.AddChild (Identifier.Create (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier);
parent.AddChild (tp, InvocationExpression.Roles.TypeParameter);
}
if (chevronLocs != null)
parent.AddChild (new CSharpTokenNode (Convert (chevronLocs[chevronLocs.Count - 1]), 1), InvocationExpression.Roles.RChevron);
}
示例4: AddTypeParameters
void AddTypeParameters (AstNode parent, List<Location> location, Mono.CSharp.TypeArguments typeArguments)
{
if (typeArguments == null || typeArguments.IsEmpty)
return;
for (int i = 0; i < typeArguments.Count; i++) {
if (location != null && i > 0 && i - 1 < location.Count)
parent.AddChild (new CSharpTokenNode (Convert (location[i - 1]), 1), InvocationExpression.Roles.Comma);
var arg = (TypeParameterName)typeArguments.Args[i];
if (arg == null)
continue;
TypeParameterDeclaration tp = new TypeParameterDeclaration();
// TODO: attributes
if (arg.Variance != Variance.None)
throw new NotImplementedException(); // TODO: variance
tp.AddChild (new Identifier (arg.Name, Convert (arg.Location)), InvocationExpression.Roles.Identifier);
parent.AddChild (tp, InvocationExpression.Roles.TypeParameter);
}
}