Exemplo n.º 1
0
 public BINValue(IBINValue parent, uint property, object value, BINValueType type)
 {
     this.Parent   = parent;
     this.Property = property;
     this.Value    = value;
     this.Type     = type;
 }
Exemplo n.º 2
0
 public BINMap(IBINValue parent, BINValueType keyType, BINValueType valueType, Dictionary <BINValue, BINValue> values)
 {
     this.Parent    = parent;
     this.KeyType   = keyType;
     this.ValueType = valueType;
     this.Values    = values;
 }
        public BINContainer(BinaryReader br, IBINValue parent)
        {
            this.Parent = parent;

            this.EntryType = (BINValueType)br.ReadByte();
            uint size       = br.ReadUInt32();
            uint valueCount = br.ReadUInt32();

            for (int i = 0; i < valueCount; i++)
            {
                this.Values.Add(new BINValue(br, this, this.EntryType));
            }
        }
        public BINMap(BinaryReader br, IBINValue parent)
        {
            this.Parent = parent;

            this.KeyType   = (BINValueType)br.ReadByte();
            this.ValueType = BINUtilities.UnpackType((BINValueType)br.ReadByte());
            uint size       = br.ReadUInt32();
            uint valueCount = br.ReadUInt32();

            for (int i = 0; i < valueCount; i++)
            {
                this.Values.Add(new BINValue(br, this, this.KeyType), new BINValue(br, this, this.ValueType));
            }
        }
Exemplo n.º 5
0
        public BINOptional(BinaryReader br, IBINValue parent)
        {
            this.Parent = parent;
            this.Type   = BINUtilities.UnpackType((BINValueType)br.ReadByte());
            byte valueCount = br.ReadByte(); //????

            if (valueCount > 1)
            {
                throw new Exception("Encountered an Optional value with Value Count: " + valueCount);
            }

            if (valueCount == 1)
            {
                this.Value = new BINValue(br, this, this.Type);
            }
        }
Exemplo n.º 6
0
        public BINValue(BinaryReader br, IBINValue parent, BINValueType?type = null)
        {
            this.Parent = parent;
            this.Type   = type;
            if (this.Type == null)
            {
                this.Property  = br.ReadUInt32();
                this.Type      = BINUtilities.UnpackType((BINValueType)br.ReadByte());
                this._typeRead = true;
            }

            if (this.Type == BINValueType.None)
            {
                this.Value = null;
            }
            else if (this.Type == BINValueType.Boolean)
            {
                this.Value = br.ReadBoolean();
            }
            else if (this.Type == BINValueType.SByte)
            {
                this.Value = br.ReadSByte();
            }
            else if (this.Type == BINValueType.Byte)
            {
                this.Value = br.ReadByte();
            }
            else if (this.Type == BINValueType.Int16)
            {
                this.Value = br.ReadInt16();
            }
            else if (this.Type == BINValueType.UInt16)
            {
                this.Value = br.ReadUInt16();
            }
            else if (this.Type == BINValueType.Int32)
            {
                this.Value = br.ReadInt32();
            }
            else if (this.Type == BINValueType.UInt32)
            {
                this.Value = br.ReadUInt32();
            }
            else if (this.Type == BINValueType.Int64)
            {
                this.Value = br.ReadInt64();
            }
            else if (this.Type == BINValueType.UInt64)
            {
                this.Value = br.ReadUInt64();
            }
            else if (this.Type == BINValueType.Float)
            {
                this.Value = br.ReadSingle();
            }
            else if (this.Type == BINValueType.FloatVector2)
            {
                this.Value = new Vector2(br);
            }
            else if (this.Type == BINValueType.FloatVector3)
            {
                this.Value = new Vector3(br);
            }
            else if (this.Type == BINValueType.FloatVector4)
            {
                this.Value = new Vector4(br);
            }
            else if (this.Type == BINValueType.Matrix44)
            {
                this.Value = new R3DMatrix44(br);
            }
            else if (this.Type == BINValueType.Color)
            {
                this.Value = br.ReadColor(ColorFormat.RgbaU8);
            }
            else if (this.Type == BINValueType.String)
            {
                this.Value = Encoding.ASCII.GetString(br.ReadBytes(br.ReadUInt16()));
            }
            else if (this.Type == BINValueType.Hash)
            {
                this.Value = br.ReadUInt32();
            }
            else if (this.Type == BINValueType.Container)
            {
                this.Value = new BINContainer(br, this);
            }
            else if (this.Type == BINValueType.Structure || this.Type == BINValueType.Embedded)
            {
                this.Value = new BINStructure(br, this);
            }
            else if (this.Type == BINValueType.LinkOffset)
            {
                this.Value = br.ReadUInt32();
            }
            else if (this.Type == BINValueType.Optional)
            {
                this.Value = new BINOptional(br, this);
            }
            else if (this.Type == BINValueType.Map)
            {
                this.Value = new BINMap(br, this);
            }
            else if (this.Type == BINValueType.FlagsBoolean)
            {
                this.Value = br.ReadBoolean();
            }
            else
            {
                throw new Exception("An Unknown Value Type was encountered: " + (byte)this.Type);
            }
        }