ReadPSSGString() публичный Метод

public ReadPSSGString ( ) : string
Результат string
Пример #1
0
        public PssgFile(System.IO.Stream fileStream)
        {
            using (PssgBinaryReader reader = new PssgBinaryReader(new BigEndianBitConverter(), fileStream))
            {
                magic = reader.ReadPSSGString(4);
                if (magic != "PSSG")
                {
                    throw new Exception("This is not a PSSG file!");
                }
                int size = reader.ReadInt32();
                int attributeInfoCount = reader.ReadInt32();
                int nodeInfoCount = reader.ReadInt32();

                attributeInfo = new PssgAttributeInfo[attributeInfoCount];
                nodeInfo = new PssgNodeInfo[nodeInfoCount];

                for (int i = 0; i < nodeInfoCount; i++)
                {
                    nodeInfo[i] = new PssgNodeInfo(reader, this);
                }
                long positionAfterInfo = reader.BaseStream.Position;

                rootNode = new PssgNode(reader, this, null, true);
                if (reader.BaseStream.Position < reader.BaseStream.Length)
                {
                    reader.BaseStream.Position = positionAfterInfo;
                    rootNode = new PssgNode(reader, this, 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.");
                    }
                }
            }
        }
Пример #2
0
        public PssgAttribute(PssgBinaryReader reader, PssgFile file, PssgNode node)
        {
            this.file = file;
            ParentNode = node;

            id = reader.ReadInt32();
            size = reader.ReadInt32();
            if (size == 4)
            {
                data = reader.ReadBytes(size);
                return;
            }
            else if (size > 4)
            {
                int strlen = reader.ReadInt32();
                if (size - 4 == strlen)
                {
                    data = reader.ReadPSSGString(strlen);
                    return;
                }
                else
                {
                    reader.Seek(-4, System.IO.SeekOrigin.Current);
                }
            }
            data = reader.ReadBytes(size);
        }
Пример #3
0
 public PssgAttributeInfo(PssgBinaryReader reader)
 {
     id = reader.ReadInt32();
     name = reader.ReadPSSGString();
 }
Пример #4
0
        public PssgNodeInfo(PssgBinaryReader reader, PssgFile file)
        {
            attributeInfo = new SortedDictionary<int, PssgAttributeInfo>();

            id = reader.ReadInt32();
            name = reader.ReadPSSGString();
            int attributeInfoCount = reader.ReadInt32();
            PssgAttributeInfo ai;
            for (int i = 0; i < attributeInfoCount; i++)
            {
                ai = new PssgAttributeInfo(reader);
                try
                {
                    attributeInfo.Add(ai.id, ai);
                }
                catch (ArgumentException ex)
                {
                    if (MessageBox.Show("The attribute of id " + ai.id + ", named " + ai.name + ", already exists, and will not be saved. Continue?",
                        "PSSG Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        continue;
                    else
                        throw new Exception("The attribute of id " + ai.id + ", named " + ai.name + ", already exists.");
                }

                file.attributeInfo[ai.id - 1] = ai;
            }
        }