Example #1
0
        /// <summary>
        /// Creates and returns any ShnColumn objects found in the given file.
        /// </summary>
        /// <returns></returns>
        private IEnumerable <ShnColumn> ReadColumns()
        {
            for (int i = 0; i < initialColumnCount; i++)
            {
                var name   = reader.ReadString(0x30);
                var type   = reader.ReadInt32();
                var length = reader.ReadInt32();
                var column = new ShnColumn(name, type, length);

                yield return(column);
            }
        }
Example #2
0
        private object ReadCell(ShnColumn column)
        {
            switch (column.Type.DataType.FullName)
            {
            case "System.Byte":
                return(reader.ReadByte());

            case "System.UInt16":
                return(reader.ReadUInt16());

            case "System.UInt32":
                return(reader.ReadUInt32());

            case "System.Single":
                return(reader.ReadSingle());

            case "System.String":
            {
                // Unknown Length
                if (column.Type.TypeId == 26)
                {
                    return(reader.ReadStringUntilZero());
                }

                return(reader.ReadString(column.Length));
            }

            case "System.Int16":
                return(reader.ReadInt16());

            case "System.SByte":
                return(reader.ReadSByte());

            case "System.Int32":
                return(reader.ReadInt32());

            default:
                Console.WriteLine("Unhandled TypeID: {0}", column.Type.TypeId);
                return(reader.ReadStringUntilZero());
            }
        }