本文整理汇总了C#中System.Compiler.TypeNode.GetTemplateType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.GetTemplateType方法的具体用法?C# TypeNode.GetTemplateType怎么用?C# TypeNode.GetTemplateType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Compiler.TypeNode
的用法示例。
在下文中一共展示了TypeNode.GetTemplateType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteStartTypeReference
/// <summary>
/// Write a starting type reference element based on the type node
/// </summary>
/// <param name="type">The type for which to write a starting type reference</param>
private void WriteStartTypeReference(TypeNode type)
{
switch(type.NodeType)
{
case NodeType.ArrayType:
ArrayType array = type as ArrayType;
writer.WriteStartElement("arrayOf");
writer.WriteAttributeString("rank", array.Rank.ToString(CultureInfo.InvariantCulture));
this.WriteTypeReference(array.ElementType);
break;
case NodeType.Reference:
Reference reference = type as Reference;
writer.WriteStartElement("referenceTo");
this.WriteTypeReference(reference.ElementType);
break;
case NodeType.Pointer:
Pointer pointer = type as Pointer;
writer.WriteStartElement("pointerTo");
this.WriteTypeReference(pointer.ElementType);
break;
case NodeType.OptionalModifier:
TypeModifier optionalModifierClause = type as TypeModifier;
this.WriteStartTypeReference(optionalModifierClause.ModifiedType);
writer.WriteStartElement("optionalModifier");
this.WriteTypeReference(optionalModifierClause.Modifier);
writer.WriteEndElement();
break;
case NodeType.RequiredModifier:
TypeModifier requiredModifierClause = type as TypeModifier;
this.WriteStartTypeReference(requiredModifierClause.ModifiedType);
writer.WriteStartElement("requiredModifier");
this.WriteTypeReference(requiredModifierClause.Modifier);
writer.WriteEndElement();
break;
default:
if(type.IsTemplateParameter)
{
ITypeParameter gtp = (ITypeParameter)type;
writer.WriteStartElement("template");
// !EFW - Change from ComponentOne
writer.WriteAttributeString("name", type.Name.Name.TranslateToValidXmlValue());
writer.WriteAttributeString("index", gtp.ParameterListIndex.ToString(CultureInfo.InvariantCulture));
writer.WriteAttributeString("api", namer.GetApiName(gtp.DeclaringMember).TranslateToValidXmlValue());
}
else
{
writer.WriteStartElement("type");
if(type.IsGeneric)
{
TypeNode template = type.GetTemplateType();
// !EFW - Change from ComponentOne
writer.WriteAttributeString("api", namer.GetTypeName(template).TranslateToValidXmlValue());
this.WriteBooleanAttribute("ref", !template.IsValueType);
// Record specialization
TypeNodeList arguments = type.TemplateArguments;
if(arguments != null && arguments.Count > 0)
{
writer.WriteStartElement("specialization");
foreach(var arg in arguments)
this.WriteTypeReference(arg);
writer.WriteEndElement();
}
}
else
{
// !EFW - Change from ComponentOne
writer.WriteAttributeString("api", namer.GetTypeName(type).TranslateToValidXmlValue());
this.WriteBooleanAttribute("ref", !type.IsValueType);
}
// Record outer types because they may be specialized and otherwise that information
// is lost.
if(type.DeclaringType != null)
this.WriteTypeReference(type.DeclaringType);
}
break;
}
}