예제 #1
0
        public static void Read(this IDictionary <string, string> _this, EndianStream stream)
        {
            int count = stream.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                string key   = stream.ReadStringAligned();
                string value = stream.ReadStringAligned();
                _this.Add(key, value);
            }
        }
예제 #2
0
        public static void Read <T>(this IDictionary <string, T> _this, EndianStream stream, Func <T> instantiator)
            where T : IStreamReadable
        {
            int count = stream.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                string key   = stream.ReadStringAligned();
                T      value = instantiator();
                value.Read(stream);
                _this.Add(key, value);
            }
        }
        public static KeyValuePair <string, T>[] ReadStringKVPArray <T>(this EndianStream stream, Func <T> valueInstantiator)
            where T : IStreamReadable
        {
            int count = stream.ReadInt32();

            KeyValuePair <string, T>[] array = new KeyValuePair <string, T> [count];
            for (int i = 0; i < count; i++)
            {
                string key   = stream.ReadStringAligned();
                T      value = valueInstantiator();
                value.Read(stream);
                KeyValuePair <string, T> kvp = new KeyValuePair <string, T>(key, value);
                array[i] = kvp;
            }
            return(array);
        }