//-----------------------------------------------------------------------
// 
//     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_OBJECTLIST 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_OBJECTLIST
    {
        /// 
        /// Size of the structure.
        /// 
        public uint cbStruct;
        /// 
        /// Tableid of the temporary table.
        /// 
        public IntPtr tableid;
        /// 
        /// Number of records in the temporary table.
        /// 
        public uint cRecord;
        /// 
        /// The id of column containing the name of the container type.
        /// 
        public uint columnidcontainername;
        /// 
        /// The id of the column containing the name of the object.
        /// 
        public uint columnidobjectname;
        /// 
        /// The id of the column containing the type of the object.
        /// 
        public uint columnidobjtyp;
        /// 
        /// Obsolete. Do not use.
        /// 
        [Obsolete("Unused member")]
        public uint columniddtCreate;
        /// 
        /// Obsolete. Do not use.
        /// 
        [Obsolete("Unused member")]
        public uint columniddtUpdate;
        /// 
        /// The id of the column containing object grbits.
        /// 
        public uint columnidgrbit;
        /// 
        /// The id of the column containing object flags.
        /// 
        public uint columnidflags;
        /// 
        /// The id of the column containing the number of records in the table.
        /// 
        public uint columnidcRecord;
        /// 
        /// The id of the column containing the number of pages the object uses.
        /// 
        public uint columnidcPage;
    }
    /// 
    /// Information about a temporary table containing information
    /// about all tables for a given database.
    /// 
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.NamingRules",
        "SA1300:ElementMustBeginWithUpperCaseLetter",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    public class JET_OBJECTLIST
    {
        /// 
        /// 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 cRecord { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the name of the table.
        /// 
        public JET_COLUMNID columnidobjectname { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the type of the table.
        /// 
        public JET_COLUMNID columnidobjtyp { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the grbits used when the table was created.
        /// 
        public JET_COLUMNID columnidgrbit { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the table flags (e.g. the system table flag).
        /// 
        public JET_COLUMNID columnidflags { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the number of records in the table.
        /// 
        public JET_COLUMNID columnidcRecord { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the name of the container.
        /// 
        public JET_COLUMNID columnidcontainername { get; internal set; }
        /// 
        /// Gets the columnid of the column in the temporary table which
        /// stores the number of pages used by the table.
        /// 
        public JET_COLUMNID columnidcPage { get; internal set; }
        /// 
        /// Returns a  that represents the current .
        /// 
        /// 
        /// A  that represents the current .
        /// 
        public override string ToString()
        {
            return string.Format(
                CultureInfo.InvariantCulture,
                "JET_OBJECTLIST(0x{0:x},{1} records)",
                this.tableid,
                this.cRecord);
        }
        /// 
        /// Sets the fields of the object from a native JET_OBJECTLIST struct.
        /// 
        /// 
        /// The native objectlist to set the values from.
        /// 
        internal void SetFromNativeObjectlist(NATIVE_OBJECTLIST value)
        {
            this.tableid = new JET_TABLEID { Value = value.tableid };
            this.cRecord = checked((int)value.cRecord);
            this.columnidobjectname = new JET_COLUMNID { Value = value.columnidobjectname };
            this.columnidobjtyp = new JET_COLUMNID { Value = value.columnidobjtyp };
            this.columnidgrbit = new JET_COLUMNID { Value = value.columnidgrbit };
            this.columnidflags = new JET_COLUMNID { Value = value.columnidflags };
            this.columnidcRecord = new JET_COLUMNID { Value = value.columnidcRecord };
            this.columnidcPage = new JET_COLUMNID { Value = value.columnidcPage };
            this.columnidcontainername = new JET_COLUMNID { Value = value.columnidcontainername };
        }
    }
}