Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dictionary"></param>
        /// <param name="reader"></param>
        /// <returns></returns>
        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);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="list"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        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);
        }