Deserialize() 공개 정적인 메소드

public static Deserialize ( BinaryReader br ) : EnumPropertyValue
br System.IO.BinaryReader
리턴 EnumPropertyValue
예제 #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);
     }
 }
예제 #2
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);
        }