mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-02-04 05:01:31 +00:00
121 lines
4.6 KiB
C#
Vendored
121 lines
4.6 KiB
C#
Vendored
//-----------------------------------------------------------------------
|
|
// <copyright file="EnumeratedColumn.cs" company="Microsoft Corporation">
|
|
// Copyright (c) Microsoft Corporation.
|
|
// </copyright>
|
|
//-----------------------------------------------------------------------
|
|
|
|
namespace Microsoft.Isam.Esent.Interop
|
|
{
|
|
using System;
|
|
using System.Globalization;
|
|
|
|
/// <summary>
|
|
/// The values for a given column as generated by Api.EnumerateColumns.
|
|
/// </summary>
|
|
public class EnumeratedColumn
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the column ID of this set of column values.
|
|
/// </summary>
|
|
public JET_COLUMNID Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the status of this column id.
|
|
/// </summary>
|
|
/// <seealso cref="JET_err.Success"/>
|
|
/// <seealso cref="JET_err.BadColumnId"/>
|
|
/// <seealso cref="JET_err.ColumnNotFound"/>
|
|
public JET_err Error { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the status of this set of column values.
|
|
/// </summary>
|
|
/// <seealso cref="JET_wrn.Success"/>
|
|
/// <seealso cref="JET_wrn.ColumnDefault"/>
|
|
/// <seealso cref="JET_wrn.ColumnNull"/>
|
|
/// <seealso cref="JET_wrn.ColumnPresent"/>
|
|
/// <seealso cref="JET_wrn.ColumnSkipped"/>
|
|
public JET_wrn Warning { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the column values enumerated.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This will be null if the column is null or the column values were not provided.
|
|
/// </remarks>
|
|
public Value[] Values { get; set; }
|
|
|
|
/// <summary>
|
|
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="EnumeratedColumn"/>.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// A <see cref="T:System.String"/> that represents the current <see cref="EnumeratedColumn"/>.
|
|
/// </returns>
|
|
public override string ToString()
|
|
{
|
|
return string.Format(
|
|
CultureInfo.InvariantCulture,
|
|
"EnumeratedColumn(0x{0:x}: {1} Values[{2}])",
|
|
this.Id,
|
|
this.Error != JET_err.Success ? this.Error.ToString() : this.Warning.ToString(),
|
|
this.Values.Length);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A single column value.
|
|
/// </summary>
|
|
public class Value
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the ordinal of this column value.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The lowest valid ordinal is one.
|
|
/// This is the same as the "itagSequence" of the column value.
|
|
/// </remarks>
|
|
public int Ordinal { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the status of this column value.
|
|
/// </summary>
|
|
/// <seealso cref="JET_wrn.Success"/>
|
|
/// <seealso cref="JET_wrn.ColumnDefault"/>
|
|
/// <seealso cref="JET_wrn.ColumnNotInRecord"/>
|
|
/// <seealso cref="JET_wrn.ColumnNull"/>
|
|
/// <seealso cref="JET_wrn.ColumnPresent"/>
|
|
/// <seealso cref="JET_wrn.ColumnSkipped"/>
|
|
/// <seealso cref="JET_wrn.ColumnTruncated"/>
|
|
public JET_wrn Warning { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the column value as bytes.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// This will be null if the column is null or the column values were not provided.
|
|
/// This will be truncated if Warning is <see cref="JET_wrn.ColumnTruncated"/>.
|
|
/// </remarks>
|
|
public byte[] Bytes { get; set; }
|
|
|
|
/// <summary>
|
|
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="EnumeratedColumn.Value"/>.
|
|
/// </summary>
|
|
/// <returns>
|
|
/// A <see cref="T:System.String"/> that represents the current <see cref="EnumeratedColumn.Value"/>.
|
|
/// </returns>
|
|
public override string ToString()
|
|
{
|
|
const int MaxLength = 16;
|
|
return string.Format(
|
|
CultureInfo.InvariantCulture,
|
|
"EnumeratedColumn.Value({0}: {1} Bytes[{2}] = {3}{4}{5}{6})",
|
|
this.Ordinal,
|
|
this.Warning,
|
|
this.Bytes.Length,
|
|
'{',
|
|
BitConverter.ToString(this.Bytes, 0, Math.Min(this.Bytes.Length, MaxLength)),
|
|
this.Bytes.Length > MaxLength ? "..." : string.Empty,
|
|
'}');
|
|
}
|
|
}
|
|
}
|
|
} |