Ejemplo n.º 1
0
        private void Read(Stream input)
        {
            BinaryReader reader            = new BinaryReader(input, Encoding.Default, true);
            uint         magicNumber1      = reader.ReadUInt32();
            uint         magicNumber2      = reader.ReadUInt32();
            int          entityCount       = reader.ReadInt32();
            int          stringTableOffset = reader.ReadInt32();
            int          offsetData        = reader.ReadInt32();

            reader.Skip(12);
            for (int i = 0; i < entityCount; i++)
            {
                FoxEntity entity = FoxEntity.ReadFoxEntity(input);
                _entities.Add(entity);
            }

            FoxStringLookupLiteral stringLookupLiteral;

            while ((stringLookupLiteral = FoxStringLookupLiteral.ReadFoxStringLookupLiteral(input)) != null)
            {
                _stringLookupLiterals.Add(stringLookupLiteral);
            }
            input.AlignRead(16);
            reader.Skip(2);
            byte[] eof = reader.ReadBytes(3);
            input.AlignRead(16);
        }
Ejemplo n.º 2
0
        public static FoxEntity ReadFoxEntity(Stream input)
        {
            FoxEntity entity = new FoxEntity();

            entity.Read(input);
            return(entity);
        }
Ejemplo n.º 3
0
        public void ReadXml(XmlReader reader)
        {
            FormatVersion = reader.GetAttribute("formatVersion");
            FileVersion   = reader.GetAttribute("fileVersion");
            DateTime originalVersion;

            DateTime.TryParseExact(reader.GetAttribute("originalVersion"), "ddd MMM dd HH:mm:ss UTCzzz yyyy",
                                   CultureInfo.InvariantCulture,
                                   DateTimeStyles.None, out originalVersion);
            OriginalVersion = originalVersion;

            bool isEmptyElement = reader.IsEmptyElement;

            reader.ReadStartElement("fox");
            if (isEmptyElement)
            {
                return;
            }

            bool isClassesElementEmpty = reader.IsEmptyElement;

            reader.ReadStartElement("classes");
            if (isClassesElementEmpty == false)
            {
                while (reader.LocalName == "class")
                {
                    FoxClass foxClass = new FoxClass();
                    foxClass.ReadXml(reader);
                    _classes.Add(foxClass);
                }
                reader.ReadEndElement();
            }

            bool isEntitiesElementEmpty = reader.IsEmptyElement;

            reader.ReadStartElement("entities");
            if (isEntitiesElementEmpty == false)
            {
                while (reader.LocalName == "entity")
                {
                    FoxEntity foxEntity = new FoxEntity();
                    foxEntity.ReadXml(reader);
                    _entities.Add(foxEntity);
                }
                reader.ReadEndElement();
            }

            reader.ReadEndElement();
        }
Ejemplo n.º 4
0
 public static FoxEntity ReadFoxEntity(Stream input)
 {
     FoxEntity entity = new FoxEntity();
     entity.Read(input);
     return entity;
 }
Ejemplo n.º 5
0
        public void ReadXml(XmlReader reader)
        {
            FormatVersion = reader.GetAttribute("formatVersion");
            FileVersion = reader.GetAttribute("fileVersion");
            DateTime originalVersion;
            DateTime.TryParseExact(reader.GetAttribute("originalVersion"), "ddd MMM dd HH:mm:ss UTCzzz yyyy",
                CultureInfo.InvariantCulture,
                DateTimeStyles.None, out originalVersion);
            OriginalVersion = originalVersion;

            bool isEmptyElement = reader.IsEmptyElement;
            reader.ReadStartElement("fox");
            if (isEmptyElement) return;

            bool isClassesElementEmpty = reader.IsEmptyElement;
            reader.ReadStartElement("classes");
            if (isClassesElementEmpty == false)
            {
                while (reader.LocalName == "class")
                {
                    FoxClass foxClass = new FoxClass();
                    foxClass.ReadXml(reader);
                    _classes.Add(foxClass);
                }
                reader.ReadEndElement();
            }

            bool isEntitiesElementEmpty = reader.IsEmptyElement;
            reader.ReadStartElement("entities");
            if (isEntitiesElementEmpty == false)
            {
                while (reader.LocalName == "entity")
                {
                    FoxEntity foxEntity = new FoxEntity();
                    foxEntity.ReadXml(reader);
                    _entities.Add(foxEntity);
                }
                reader.ReadEndElement();
            }

            reader.ReadEndElement();
        }