Blaze.Server.TdfDecoder.DecodeTdfMap C# (CSharp) Method

DecodeTdfMap() private method

private DecodeTdfMap ( string label ) : TdfMap
label string
return TdfMap
        private TdfMap DecodeTdfMap(string label)
        {
            // read list types
            var listType1 = (TdfBaseType)_stream.ReadByte();
            var listType2 = (TdfBaseType)_stream.ReadByte();

            // read list size
            int listSize = _stream.ReadByte();

            var map = new TdfMap(label, listType1, listType2, new Dictionary<object, object>());

            // read list
            Func<TdfBaseType, Object> readListItem = (type) =>
            {
                Object item = null;

                switch (type)
                {
                    case TdfBaseType.Integer:
                        item = DecodeInteger();
                        break;

                    case TdfBaseType.String:
                        item = DecodeString();
                        break;

                    case TdfBaseType.Struct:
                        item = DecodeStruct();
                        break;

                    default:
                        Log.Warn(string.Format("Unknown list item type: {0}", type));
                        break;
                }

                return item;
            };

            for (int i = 0; i < listSize; i++)
            {
                Object key = readListItem(listType1);
                Object value = readListItem(listType2);

                if (key != null | value != null)
                {
                    map.Map.Add(key, value);
                }
            }

            return map;
        }