Пример #1
0
 protected virtual void DeserializeValue(BinaryReader br)
 {
     if (Type == "IntProperty")
     {
         Value = br.ReadInt32();
     }
     else if (Type == "StrProperty" || Type == "NameProperty")
     {
         Value = br.ReadString2();
     }
     else if (Type == "FloatProperty")
     {
         Value = br.ReadSingle();
     }
     else if (Type == "ByteProperty")
     {
         // how is this a byte property?
         Value = EnumPropertyValue.Deserialize(br);
     }
     else if (Type == "BoolProperty")
     {
         Value = br.ReadByte();
     }
     else if (Type == "QWordProperty")
     {
         Value = br.ReadInt64();
     }
     else
     {
         throw new InvalidDataException("Unknown property: " + Type);
     }
 }
 public static EnumPropertyValue Deserialize(BinaryReader br)
 {
     var epv = new EnumPropertyValue()
     {
         Type = br.ReadString2(),
         Value = br.ReadString2()
     };
     return epv;
 }
        public static EnumPropertyValue Deserialize(BinaryReader br)
        {
            var epv = new EnumPropertyValue()
            {
                Type  = br.ReadString2(),
                Value = br.ReadString2()
            };

            return(epv);
        }
Пример #4
0
        public static Property Deserialize(BinaryReader br)
        {
            var p = new Property();

            p.Name = br.ReadString2();
            if (p.Name != "None")
            {
                p.Type       = br.ReadString2();
                p.DataLength = br.ReadInt32();
                p.Unknown    = br.ReadInt32();

                if (p.Type == "IntProperty")
                {
                    p.Value = br.ReadInt32();
                }
                else if (p.Type == "StrProperty" || p.Type == "NameProperty")
                {
                    p.Value = br.ReadString2();
                }
                else if (p.Type == "FloatProperty")
                {
                    p.Value = br.ReadSingle();
                }
                else if (p.Type == "ByteProperty")
                {
                    // how is this a byte property?
                    p.Value = EnumPropertyValue.Deserialize(br);
                }
                else if (p.Type == "BoolProperty")
                {
                    p.Value = br.ReadByte();
                }
                else if (p.Type == "QWordProperty")
                {
                    p.Value = br.ReadInt64();
                }
                else if (p.Type == "ArrayProperty")
                {
                    var propertyLists = new List <PropertyDictionary>();
                    var len           = br.ReadInt32();
                    for (int i = 0; i < len; ++i)
                    {
                        var properties = PropertyDictionary.Deserialize(br);
                        propertyLists.Add(properties);
                    }
                    p.Value = propertyLists;
                }
                else
                {
                    throw new InvalidDataException("Unknown property: " + p.Type);
                }
            }

            return(p);
        }