当前位置: 首页>>代码示例>>C#>>正文


C# AttributeType.GetKindName方法代码示例

本文整理汇总了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));
     }
 }
开发者ID:jblomer,项目名称:GrGen.NET,代码行数:64,代码来源:GrsExport.cs


注:本文中的AttributeType.GetKindName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。