コード例 #1
0
ファイル: DataValue.cs プロジェクト: laszlo-kiss/Dataphor
        /// <summary>Returns the host representation of the given physical value.</summary>
        public static IDataValue FromPhysical(IValueManager manager, Schema.IDataType dataType, byte[] buffer, int offset)
        {
            Schema.IScalarType scalarType = dataType as Schema.IScalarType;
            if (scalarType != null)
            {
                Scalar scalar = new Scalar(manager, scalarType, null);
                scalar.ReadFromPhysical(buffer, offset);
                return(scalar);
            }

            Schema.IRowType rowType = dataType as Schema.IRowType;
            if (rowType != null)
            {
                Row row = new Row(manager, rowType);
                row.ReadFromPhysical(buffer, offset);
                return(row);
            }

            Schema.IListType listType = dataType as Schema.IListType;
            if (listType != null)
            {
                ListValue list = new ListValue(manager, listType);
                list.ReadFromPhysical(buffer, offset);
                return(list);
            }

            Schema.ITableType tableType = dataType as Schema.ITableType;
            if (tableType != null)
            {
                TableValue table = new TableValue(manager, tableType, null);
                table.ReadFromPhysical(buffer, offset);
                return(table);
            }

            Schema.ICursorType cursorType = dataType as Schema.ICursorType;
            if (cursorType != null)
            {
                CursorValue cursor = new CursorValue(manager, cursorType, -1);
                cursor.ReadFromPhysical(buffer, offset);
                return(cursor);
            }

            throw new RuntimeException(RuntimeException.Codes.InvalidValueType, dataType == null ? "<null>" : dataType.GetType().Name);
        }