Exemple #1
0
        protected override void ReadMembers(SR1_Reader reader, SR1_Structure parent)
        {
            for (int i = 0; i < _List.Count; i++)
            {
                Type type = _List[i].GetType();
                if (type == typeof(SR1Structures.EventBasicObject))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.EventBasicObject tempEBO = new SR1Structures.EventBasicObject();
                    tempEBO.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _List[i] = (T)tempEBO.CreateReplacementObject();
                }
                else if (type == typeof(SR1Structures.ObjectSound))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.ObjectSound tempOS = new SR1Structures.ObjectSound();
                    tempOS.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _List[i] = (T)tempOS.CreateReplacementObject();
                }
                else if (type == typeof(SR1Structures.PhysObProperties))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.PhysObProperties tempPOP = new SR1Structures.PhysObProperties();
                    tempPOP.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _List[i] = (T)tempPOP.CreateReplacementObject();
                }
                else if (type == typeof(SR1Structures.VMObject))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.VMObject tempVMO = new SR1Structures.VMObject();
                    tempVMO.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _List[i] = (T)tempVMO.CreateReplacementObject();
                }

                _List[i].Read(reader, this, "[" + i.ToString() + "]");
            }
        }
        public override object CreateObject(SR1_Structure parent, SR1_Reader reader)
        {
            if (typeof(T) == typeof(SR1Structures.EventBasicObject))
            {
                long oldPosition = reader.BaseStream.Position;
                SR1Structures.EventBasicObject tempEBO = new SR1Structures.EventBasicObject();
                tempEBO.ReadTemp(reader);
                reader.BaseStream.Position = oldPosition;

                return(tempEBO.CreateReplacementObject());
            }
            else if (typeof(T) == typeof(SR1Structures.ObjectSound))
            {
                long oldPosition = reader.BaseStream.Position;
                SR1Structures.ObjectSound tempOS = new SR1Structures.ObjectSound();
                tempOS.ReadTemp(reader);
                reader.BaseStream.Position = oldPosition;

                return(tempOS.CreateReplacementObject());
            }
            else if (typeof(T) == typeof(SR1Structures.PhysObProperties))
            {
                long oldPosition = reader.BaseStream.Position;
                SR1Structures.PhysObProperties tempPOP = new SR1Structures.PhysObProperties();
                tempPOP.ReadTemp(reader);
                reader.BaseStream.Position = oldPosition;

                return(tempPOP.CreateReplacementObject());
            }
            else if (typeof(T) == typeof(SR1Structures.VMObject))
            {
                long oldPosition = reader.BaseStream.Position;
                SR1Structures.VMObject tempVMO = new SR1Structures.VMObject();
                tempVMO.ReadTemp(reader);
                reader.BaseStream.Position = oldPosition;

                return(tempVMO.CreateReplacementObject());
            }

            return(new T());
        }
        protected override void ReadMembers(SR1_Reader reader, SR1_Structure parent)
        {
            for (int i = 0; i < _array.Length; i++)
            {
                Type type = _array[i].GetType();
                if (type == typeof(SR1Structures.EventBasicObject))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.EventBasicObject tempEBO = new SR1Structures.EventBasicObject();
                    tempEBO.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _array[i] = (T)tempEBO.CreateReplacementObject();
                }
                else if (type == typeof(SR1Structures.ObjectSound))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.ObjectSound tempOS = new SR1Structures.ObjectSound();
                    tempOS.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _array[i] = (T)tempOS.CreateReplacementObject();
                }
                else if (type == typeof(SR1Structures.PhysObProperties))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.PhysObProperties tempPOP = new SR1Structures.PhysObProperties();
                    tempPOP.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _array[i] = (T)tempPOP.CreateReplacementObject();
                }
                else if (type == typeof(SR1Structures.VMObject))
                {
                    long oldPosition = reader.BaseStream.Position;
                    SR1Structures.VMObject tempVMO = new SR1Structures.VMObject();
                    tempVMO.ReadTemp(reader);
                    reader.BaseStream.Position = oldPosition;

                    _array[i] = (T)tempVMO.CreateReplacementObject();
                }


                string elementName = "";
                int    index       = i;
                int    d           = _dimensions.Length;
                while (d > 0)
                {
                    d--;
                    int subIndex = index % _dimensions[d];
                    index /= _dimensions[d];
                    string indexName = "";
                    indexName  += "[";
                    indexName  += subIndex.ToString();
                    indexName  += "]";
                    indexName  += elementName;
                    elementName = indexName;
                }

                _array[i].Read(reader, this, elementName);
            }
        }