public static YAMLNode ExportYAML <T>(this IReadOnlyDictionary <Tuple <T, long>, string> _this, Func <T, int> converter)
        {
            YAMLSequenceNode node = new YAMLSequenceNode(SequenceStyle.BlockCurve);

            foreach (var kvp in _this)
            {
                YAMLMappingNode keyNode = new YAMLMappingNode();
                keyNode.Add(converter(kvp.Key.Item1), kvp.Key.Item2);
                YAMLMappingNode kvpMap = new YAMLMappingNode();
                kvpMap.Add("first", keyNode);
                kvpMap.Add("second", kvp.Value);
                node.Add(kvpMap);
            }
            return(node);
        }
        public static YAMLNode ExportYAML(this IReadOnlyDictionary <Tuple <ushort, ushort>, float> _this)
        {
            YAMLSequenceNode node = new YAMLSequenceNode(SequenceStyle.BlockCurve);

            foreach (var kvp in _this)
            {
                YAMLMappingNode keyNode = new YAMLMappingNode();
                keyNode.Add(kvp.Key.Item1, kvp.Key.Item2);
                YAMLMappingNode kvpMap = new YAMLMappingNode();
                kvpMap.Add("first", keyNode);
                kvpMap.Add("second", kvp.Value);
                node.Add(kvpMap);
            }
            return(node);
        }
Example #3
0
 public static YAMLNode ExportYAML(this IEnumerable <uint> _this, bool isRaw)
 {
     if (isRaw)
     {
         StringBuilder sb = new StringBuilder();
         foreach (uint value in _this)
         {
             sb.AppendHex(value);
         }
         return(new YAMLScalarNode(sb.ToString()));
     }
     else
     {
         YAMLSequenceNode node = new YAMLSequenceNode(SequenceStyle.Block);
         foreach (uint value in _this)
         {
             node.Add(value);
         }
         return(node);
     }
 }
 public static YAMLNode ExportYAML(this IReadOnlyList <short> _this, bool isRaw)
 {
     if (isRaw)
     {
         StringBuilder sb = new StringBuilder(_this.Count * 4);
         foreach (short value in _this)
         {
             sb.AppendHex(value);
         }
         return(new YAMLScalarNode(sb.ToString(), true));
     }
     else
     {
         YAMLSequenceNode node = new YAMLSequenceNode(SequenceStyle.Block);
         foreach (short value in _this)
         {
             node.Add(value);
         }
         return(node);
     }
 }