Exemple #1
0
        private PsoArray Read14Array(XmlNode node)
        {
            var arrayValue = new PsoArray();

            if (node.ChildNodes.Count > 0)
            {
                arrayValue.Entries = new List <IPsoValue>();
                foreach (XmlNode arrent in node.ChildNodes)
                {
                    var y = new PsoType14();
                    y.Value = FromHex(arrent.Value);
                    arrayValue.Entries.Add(y);
                }
            }
            return(arrayValue);
        }
Exemple #2
0
        private PsoArray Read11Array(XmlNode node)
        {
            var arrayValue = new PsoArray();

            if (node.ChildNodes.Count > 0)
            {
                arrayValue.Entries = new List <IPsoValue>();
                foreach (XmlNode arrent in node.ChildNodes)
                {
                    var y = new PsoType11(0);
                    y.Value     = null;
                    y.ValueHash = GetHashForName(arrent.InnerText);
                    arrayValue.Entries.Add(y);
                }
            }
            return(arrayValue);
        }
Exemple #3
0
        private PsoArray ReadStructureArray(XmlNode node, int structureNameHash)
        {
            var arrayValue = new PsoArray();
            var arrayType  = structureNameHash;

            if (node.ChildNodes.Count > 0)
            {
                arrayValue.Entries = new List <IPsoValue>();
                foreach (XmlNode arrent in node.ChildNodes)
                {
                    var xnd = FindAndCheckStructure(arrayType, arrent);
                    var yy  = ParseStructure(arrent, xnd);
                    arrayValue.Entries.Add(yy);
                }
            }
            return(arrayValue);
        }
Exemple #4
0
        public PsoStructure ParseStructure(XmlNode node, PsoStructureXml info)
        {
            PsoStructure resultStructure = null;

            foreach (var x in strList)
            {
                if (x.Item1 == info.NameHash)
                {
                    resultStructure                       = new PsoStructure();
                    resultStructure.psoSection            = x.Item2;
                    resultStructure.psoEntryInfo          = new PsoElementIndexInfo();
                    resultStructure.psoEntryInfo.NameHash = x.Item1;
                }
            }

            resultStructure.Values = new Dictionary <int, IPsoValue>();

            foreach (var xmlEntry in info.Entries)
            {
                XmlNode xmlNode = null;
                foreach (XmlNode x in node.ChildNodes)
                {
                    var hash = GetHashForName(x.Name);
                    if (hash == xmlEntry.NameHash)
                    {
                        xmlNode = x;
                    }
                }

                PsoStructureEntryInfo entryInfo = null;
                foreach (var x in resultStructure.psoSection.Entries)
                {
                    if (x.EntryNameHash == xmlEntry.NameHash)
                    {
                        entryInfo = x;
                    }
                }

                var type = (DataType)xmlEntry.Type;
                if (type == DataType.Array)
                {
                    var arrayType = (DataType)xmlEntry.ArrayType.Type;
                    if (arrayType == DataType.Structure)
                    {
                        PsoArray arrayValue = ReadStructureArray(xmlNode, xmlEntry.ArrayType.TypeHash);
                        arrayValue.psoSection = resultStructure.psoSection.Entries[entryInfo.ReferenceKey];
                        resultStructure.Values.Add(xmlEntry.NameHash, arrayValue);
                    }
                    else if (arrayType == DataType.INT_0Bh)
                    {
                        PsoArray arryVal = Read11Array(xmlNode);
                        arryVal.psoSection = resultStructure.psoSection.Entries[entryInfo.ReferenceKey];
                        resultStructure.Values.Add(xmlEntry.NameHash, arryVal);
                    }
                    else if (arrayType == DataType.SHORT_0Fh)
                    {
                        PsoArray arryVal = Read14Array(xmlNode);
                        arryVal.psoSection = resultStructure.psoSection.Entries[entryInfo.ReferenceKey];
                        resultStructure.Values.Add(xmlEntry.NameHash, arryVal);
                    }
                    else
                    {
                        throw new Exception("Unsupported array type.");
                    }
                }
                else if (type == DataType.INT_06h)
                {
                    resultStructure.Values.Add(xmlEntry.NameHash, ReadType6(xmlNode));
                }
                else if (type == DataType.INT_0Bh)
                {
                    resultStructure.Values.Add(xmlEntry.NameHash, ReadType11(xmlNode, xmlEntry.Unknown == 0));
                }
                else if (type == DataType.BYTE_ENUM_VALUE)
                {
                    resultStructure.Values.Add(xmlEntry.NameHash, ReadType14(xmlNode));
                }
                else if (type == DataType.SHORT_0Fh)
                {
                    resultStructure.Values.Add(xmlEntry.NameHash, ReadType15(xmlNode));
                }
                else if (type == DataType.Structure)
                {
                    var xmlInfo        = FindAndCheckStructure(xmlEntry.TypeHash, xmlNode);
                    var structureValue = ParseStructure(xmlNode, xmlInfo);
                    resultStructure.Values.Add(xmlEntry.NameHash, structureValue);
                }
                else
                {
                    throw new Exception("Unsupported type.");
                }
            }

            return(resultStructure);
        }