//-----------------------------------------------------------------------
// 
//     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_OBJECTINFO 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_OBJECTINFO
    {
        /// 
        /// Size of the structure.
        /// 
        public uint cbStruct;
        /// 
        /// Holds the JET_OBJTYP of the structure. Currently only tables will be
        /// returned (that is, ).
        /// 
        public uint objtyp;
        /// 
        /// Obsolete. Do not use.
        /// 
        [Obsolete("Unused member")]
        public double ignored1;
        /// 
        /// Obsolete. Do not use.
        /// 
        [Obsolete("Unused member")]
        public double ignored2;
        /// 
        /// A group of bits that contain table options.
        /// 
        public uint grbit;
        /// 
        /// Table type flags.
        /// 
        public uint flags;
        /// 
        /// Number of records in the table.
        /// 
        public uint cRecord;
        /// 
        /// Number of pages used by the table.
        /// 
        public uint cPage;
    }
    /// 
    /// The JET_OBJECTINFO structure holds information about an object.
    /// Tables are the only object types that are currently supported.
    /// 
    [SuppressMessage(
        "Microsoft.StyleCop.CSharp.NamingRules",
        "SA1300:ElementMustBeginWithUpperCaseLetter",
        Justification = "This should match the unmanaged API, which isn't capitalized.")]
    public class JET_OBJECTINFO
    {
        /// 
        /// Gets the JET_OBJTYP of the table. Currently only tables will be
        /// returned (that is, ).
        /// 
        public JET_objtyp objtyp { get; private set; }
        /// 
        /// Gets the table options.
        /// 
        public ObjectInfoGrbit grbit { get; private set; }
        /// 
        /// Gets the table type flags.
        /// 
        public ObjectInfoFlags flags { get; private set; }
        /// 
        /// Gets the number of records in the table.
        /// 
        public int cRecord { get; private set; }
        /// 
        /// Gets the number of pages used by the table.
        /// 
        public int cPage { get; private set; }
        /// 
        /// Returns a  that represents the current .
        /// 
        /// 
        /// A  that represents the current .
        /// 
        public override string ToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "JET_OBJECTINFO({0})", this.flags);
        }
        /// 
        /// Sets the fields of the object from a native JET_OBJECTINFO struct.
        /// 
        /// 
        /// The native objectlist to set the values from.
        /// 
        internal void SetFromNativeObjectinfo(ref NATIVE_OBJECTINFO value)
        {
            unchecked
            {
                this.objtyp = (JET_objtyp)value.objtyp;
                this.grbit = (ObjectInfoGrbit)value.grbit;
                this.flags = (ObjectInfoFlags)value.flags;
                this.cRecord = (int)value.cRecord;
                this.cPage = (int)value.cPage;
            }
        }
    }
}