LSLib.LS.LSF.LSFReader.ReadAttribute C# (CSharp) Méthode

ReadAttribute() private méthode

private ReadAttribute ( NodeAttribute type, BinaryReader reader, uint length ) : NodeAttribute
type NodeAttribute
reader System.IO.BinaryReader
length uint
Résultat NodeAttribute
        private NodeAttribute ReadAttribute(NodeAttribute.DataType type, BinaryReader reader, uint length)
        {
            // LSF and LSB serialize the buffer types differently, so specialized
            // code is added to the LSB and LSf serializers, and the common code is
            // available in BinUtils.ReadAttribute()
            switch (type)
            {
                case NodeAttribute.DataType.DT_String:
                case NodeAttribute.DataType.DT_Path:
                case NodeAttribute.DataType.DT_FixedString:
                case NodeAttribute.DataType.DT_LSString:
                case NodeAttribute.DataType.DT_WString:
                case NodeAttribute.DataType.DT_LSWString:
                { 
                    var attr = new NodeAttribute(type);
                    attr.Value = ReadString(reader, (int)length);
                    return attr;
                }

                case NodeAttribute.DataType.DT_TranslatedString:
                {
                    var attr = new NodeAttribute(type);
                    var str = new TranslatedString();
                    var valueLength = reader.ReadInt32();
                    str.Value = ReadString(reader, valueLength);
                    var handleLength = reader.ReadInt32();
                    str.Handle = ReadString(reader, handleLength);
                    attr.Value = str;
                    return attr;
                }

                case NodeAttribute.DataType.DT_ScratchBuffer:
                { 
                    var attr = new NodeAttribute(type);
                    attr.Value = reader.ReadBytes((int)length);
                    return attr;
                }

                default:
                    return BinUtils.ReadAttribute(type, reader);
            }
        }