Ejemplo n.º 1
0
        public static PssgFile ReadPssg(Stream fileStream, PssgFileType fileType)
        {
            PssgFile file = new PssgFile(fileType);

            using (PssgBinaryReader reader = new PssgBinaryReader(EndianBitConverter.Big, fileStream, true))
            {
                reader.ReadPSSGString(4); // "PSSG"
                int size = reader.ReadInt32();

                // Load all the pssg node/attribute names
                PssgSchema.ClearSchemaIds();
                PssgSchema.LoadFromPssg(reader);
                long positionAfterInfo = reader.BaseStream.Position;

                file.RootNode = new PssgNode(reader, file, null, true);
                if (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    reader.BaseStream.Position = positionAfterInfo;
                    file.RootNode = new PssgNode(reader, file, null, false);
                    if (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        throw new Exception("This file is improperly saved and not supported by this version of the PSSG editor." + Environment.NewLine + Environment.NewLine +
                                            "Get an older version of the program if you wish to take out its contents, but put it back together using this program and the original version of the pssg file.");
                    }
                }
            }

            return(file);
        }
Ejemplo n.º 2
0
        public static void LoadFromPssg(PssgBinaryReader reader)
        {
            int       attributeInfoCount = reader.ReadInt32();
            int       nodeInfoCount      = reader.ReadInt32();
            Node      node;
            Attribute attribute;

            for (int i = 0; i < nodeInfoCount; i++)
            {
                int nId = reader.ReadInt32();
                node    = new Node(reader.ReadPSSGString());
                node.Id = nId;

                if (entries.ContainsKey(node.Name))
                {
                    entries[node.Name].Id = node.Id;
                }
                else
                {
                    PssgSchema.AddNode(node);
                }

                int subAttributeInfoCount = reader.ReadInt32();
                for (int j = 0; j < subAttributeInfoCount; j++)
                {
                    int id = reader.ReadInt32();
                    attribute    = new Attribute(reader.ReadPSSGString());
                    attribute.Id = id;

                    Attribute attr = PssgSchema.GetAttribute(node.Name, attribute.Name);
                    if (attr == null)
                    {
                        PssgSchema.AddAttribute(node.Name, attribute);
                    }
                    else
                    {
                        attr.Id = attribute.Id;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static PssgFile ReadPssg(Stream fileStream, PssgFileType fileType)
        {
            PssgFile file = new PssgFile(fileType);

            using (PssgBinaryReader reader = new PssgBinaryReader(new BigEndianBitConverter(), fileStream))
            {
                reader.ReadPSSGString(4); // "PSSG"
                int size = reader.ReadInt32();

                // Load all the pssg node/attribute names
                PssgSchema.ClearSchemaIds();
                PssgSchema.LoadFromPssg(reader);
                long positionAfterInfo = reader.BaseStream.Position;

                file.RootNode = new PssgNode(reader, file, null, true);
                if (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    reader.BaseStream.Position = positionAfterInfo;
                    file.RootNode = new PssgNode(reader, file, null, false);
                    if (reader.BaseStream.Position < reader.BaseStream.Length)
                    {
                        throw new Exception("This file is improperly saved and not supported by this version of the PSSG editor." + Environment.NewLine + Environment.NewLine +
                            "Get an older version of the program if you wish to take out its contents, but put it back together using this program and the original version of the pssg file.");
                    }
                }
            }

            return file;
        }
Ejemplo n.º 4
0
        public static void LoadFromPssg(PssgBinaryReader reader)
        {
            int attributeInfoCount = reader.ReadInt32();
            int nodeInfoCount = reader.ReadInt32();
            Node node;
            Attribute attribute;

            for (int i = 0; i < nodeInfoCount; i++)
            {
                int nId = reader.ReadInt32();
                node = new Node(reader.ReadPSSGString());
                node.Id = nId;

                if (entries.ContainsKey(node.Name))
                {
                    entries[node.Name].Id = node.Id;
                }
                else
                {
                    PssgSchema.AddNode(node);
                }

                int subAttributeInfoCount = reader.ReadInt32();
                for (int j = 0; j < subAttributeInfoCount; j++)
                {
                    int id = reader.ReadInt32();
                    attribute = new Attribute(reader.ReadPSSGString());
                    attribute.Id = id;

                    Attribute attr = PssgSchema.GetAttribute(node.Name, attribute.Name);
                    if (attr == null)
                    {
                        PssgSchema.AddAttribute(node.Name, attribute);
                    }
                    else
                    {
                        attr.Id = attribute.Id;
                    }
                }
            }
        }