//-----------------------------------------------------------------------
// 
//     Copyright (c) Microsoft Corporation.
// 
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Runtime.InteropServices;
    /// 
    /// The native version of the JET_RECORDLIST structure.
    /// 
    [StructLayout(LayoutKind.Sequential)]
    [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules",
        "SA1305:FieldNamesMustNotUseHungarianNotation",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.NamingRules",
        "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    internal struct NATIVE_RECORDLIST
    {
        /// 
        /// Size of the structure.
        /// 
        public uint cbStruct;
        /// 
        /// Temporary table containing the bookmarks.
        /// 
        public IntPtr tableid;
        /// 
        /// Number of records in the table.
        /// 
        public uint cRecords;
        /// 
        /// Column id of the column containing the record bookmarks.
        /// 
        public uint columnidBookmark;
    }
    /// 
    /// Information about a temporary table containing information
    /// about all indexes for a given table.
    /// 
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.NamingRules",
        "SA1300:ElementMustBeginWithUpperCaseLetter",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    public class JET_RECORDLIST
    {
        /// 
        /// Gets tableid of the temporary table. This should be closed
        /// when the table is no longer needed.
        /// 
        public JET_TABLEID tableid { get; internal set; }
        /// 
        /// Gets the number of records in the temporary table.
        /// 
        public int cRecords { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the bookmark of the record.
        /// The column is of type JET_coltyp.Text.
        /// 
        public JET_COLUMNID columnidBookmark { get; internal set; }
        /// 
        /// Returns a  that represents the current .
        /// 
        /// 
        /// A  that represents the current .
        /// 
        public override string ToString()
        {
            return string.Format(
                CultureInfo.InvariantCulture,
                "JET_RECORDLIST(0x{0:x},{1} records)",
                this.tableid,
                this.cRecords);
        }
        /// 
        /// Sets the fields of the object from a native JET_RECORDLIST struct.
        /// 
        /// 
        /// The native recordlist to set the values from.
        /// 
        internal void SetFromNativeRecordlist(NATIVE_RECORDLIST value)
        {
            this.tableid = new JET_TABLEID { Value = value.tableid };
            this.cRecords = checked((int)value.cRecords);
            this.columnidBookmark = new JET_COLUMNID { Value = value.columnidBookmark };
        }
    }
}