Пример #1
0
        public static Dictionary <string, string> FromReader(this Dictionary <string, string> dictionary,
                                                             EndianBinaryReader reader)
        {
            var count = reader.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var key   = reader.ReadString();
                var value = reader.ReadString();
                if (dictionary.ContainsKey(key))
                {
                    dictionary[key] = value;
                }
                else
                {
                    dictionary.Add(key, value);
                }
            }

            return(dictionary);
        }
Пример #2
0
        public static List <string> FromBytes(this List <string> list, byte[] data)
        {
            using (var ms = new MemoryStream(data)) {
                using (var reader = new EndianBinaryReader(EndianBitConverter.Big, ms)) {
                    var count = reader.ReadInt32();

                    for (var i = 0; i < count; i++)
                    {
                        list.Add(reader.ReadString());
                    }
                }
            }

            return(list);
        }