Beispiel #1
0
        public UScriptMap(FAssetArchive Ar, FPropertyTagData tagData)
        {
            if (tagData.InnerType == null || tagData.ValueType == null)
            {
                throw new ParserException(Ar, "Can't serialize UScriptMap without key or value type");
            }

            var numKeysToRemove = Ar.Read <int>();

            for (var i = 0; i < numKeysToRemove; i++)
            {
                FPropertyTagType.ReadPropertyTagType(Ar, tagData.InnerType, tagData.InnerTypeData, ReadType.MAP);
            }

            var numEntries = Ar.Read <int>();

            Properties = new Dictionary <FPropertyTagType?, FPropertyTagType?>(numEntries);
            for (var i = 0; i < numEntries; i++)
            {
                var isReadingValue = false;
                try
                {
                    var key = FPropertyTagType.ReadPropertyTagType(Ar, tagData.InnerType, tagData.InnerTypeData, ReadType.MAP);
                    isReadingValue = true;
                    var value = FPropertyTagType.ReadPropertyTagType(Ar, tagData.ValueType, tagData.ValueTypeData, ReadType.MAP);
                    Properties[key] = value;
                }
                catch (ParserException e)
                {
                    throw new ParserException(Ar, $"Failed to read {(isReadingValue ? "value" : "key")} for index {i} in map", e);
                }
            }
        }
Beispiel #2
0
        public UScriptMap(FAssetArchive Ar, FPropertyTagData tagData)
        {
            if (tagData.InnerType == null || tagData.ValueType == null)
            {
                throw new ParserException(Ar, "Can't serialize UScriptMap without key or value type");
            }

            int numKeyToRemove = Ar.Read <int>();

            for (int i = 0; i < numKeyToRemove; i++)
            {
                FPropertyTagType.ReadPropertyTagType(Ar, tagData.InnerType, tagData, ReadType.MAP);
            }

            int numEntries = Ar.Read <int>();

            Properties = new Dictionary <FPropertyTagType?, FPropertyTagType?>(numEntries);
            for (int i = 0; i < numEntries; i++)
            {
                try
                {
                    Properties[FPropertyTagType.ReadPropertyTagType(Ar, tagData.InnerType, tagData.InnerTypeData, ReadType.MAP)] = FPropertyTagType.ReadPropertyTagType(Ar, tagData.ValueType, tagData.ValueTypeData, ReadType.MAP);
                }
                catch (ParserException e)
                {
                    throw new ParserException(Ar, $"Failed to read key/value pair for index {i} in map", e);
                }
            }
        }