本文整理汇总了C#中AttributeType.GetKindName方法的典型用法代码示例。如果您正苦于以下问题:C# AttributeType.GetKindName方法的具体用法?C# AttributeType.GetKindName怎么用?C# AttributeType.GetKindName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeType
的用法示例。
在下文中一共展示了AttributeType.GetKindName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitAttribute
/// <summary>
/// Emits the attribute value as code
/// for an attribute of the given type with the given value into the stream writer
/// Main graph context is needed to get access to the graph -> env dictionary.
/// </summary>
public static void EmitAttribute(MainGraphExportContext mainGraphContext,
AttributeType attrType, object value, INamedGraph graph, StreamWriter sw)
{
if(attrType.Kind==AttributeKind.SetAttr)
{
IDictionary set=(IDictionary)value;
sw.Write("{0}{{", attrType.GetKindName());
bool first = true;
foreach(DictionaryEntry entry in set)
{
if(first) { sw.Write(ToString(mainGraphContext, entry.Key, attrType.ValueType, graph)); first = false; }
else { sw.Write("," + ToString(mainGraphContext, entry.Key, attrType.ValueType, graph)); }
}
sw.Write("}");
}
else if(attrType.Kind==AttributeKind.MapAttr)
{
IDictionary map=(IDictionary)value;
sw.Write("{0}{{", attrType.GetKindName());
bool first = true;
foreach(DictionaryEntry entry in map)
{
if(first) { sw.Write(ToString(mainGraphContext, entry.Key, attrType.KeyType, graph)
+ "->" + ToString(mainGraphContext, entry.Value, attrType.ValueType, graph)); first = false;
}
else { sw.Write("," + ToString(mainGraphContext, entry.Key, attrType.KeyType, graph)
+ "->" + ToString(mainGraphContext, entry.Value, attrType.ValueType, graph)); }
}
sw.Write("}");
}
else if(attrType.Kind == AttributeKind.ArrayAttr)
{
IList array = (IList)value;
sw.Write("{0}[", attrType.GetKindName());
bool first = true;
foreach(object entry in array)
{
if(first) { sw.Write(ToString(mainGraphContext, entry, attrType.ValueType, graph)); first = false; }
else { sw.Write("," + ToString(mainGraphContext, entry, attrType.ValueType, graph)); }
}
sw.Write("]");
}
else if(attrType.Kind == AttributeKind.DequeAttr)
{
IDeque deque = (IDeque)value;
sw.Write("{0}]", attrType.GetKindName());
bool first = true;
foreach(object entry in deque)
{
if(first) { sw.Write(ToString(mainGraphContext, entry, attrType.ValueType, graph)); first = false; }
else { sw.Write("," + ToString(mainGraphContext, entry, attrType.ValueType, graph)); }
}
sw.Write("[");
}
else
{
sw.Write("{0}", ToString(mainGraphContext, value, attrType, graph));
}
}