//-----------------------------------------------------------------------
// 
//     Copyright (c) Microsoft Corporation.
// 
//-----------------------------------------------------------------------
namespace Microsoft.Isam.Esent.Interop
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    /// 
    /// Information about one Esent column. This is not an interop
    /// class, but is used by the meta-data helper methods.
    /// 
    public sealed class ColumnInfo
    {
        /// 
        /// The default value of the column.
        /// 
        private readonly ReadOnlyCollection defaultValue;
        /// 
        /// Initializes a new instance of the ColumnInfo class.
        /// 
        /// Name of the column.
        /// ID of the column.
        /// Type of the column.
        /// Codepage of the column.
        /// Maximum length of the column.
        /// Column default value.
        /// Column option.
        internal ColumnInfo(
            string name,
            JET_COLUMNID columnid,
            JET_coltyp coltyp,
            JET_CP cp,
            int maxLength,
            byte[] defaultValue,
            ColumndefGrbit grbit)
        {
            this.Name = name;
            this.Columnid = columnid;
            this.Coltyp = coltyp;
            this.Cp = cp;
            this.MaxLength = maxLength;
            this.defaultValue = (null == defaultValue) ? null : new ReadOnlyCollection(defaultValue);
            this.Grbit = grbit;
        }
        /// 
        /// Gets the name of the column.
        /// 
        public string Name { get; private set; }
        /// 
        /// Gets the ID of the column.
        /// 
        public JET_COLUMNID Columnid { get; private set; }
        /// 
        /// Gets the type of the column.
        /// 
        public JET_coltyp Coltyp { get; private set; }
        /// 
        /// Gets the code page of the column.
        /// 
        public JET_CP Cp { get; private set; }
        /// 
        /// Gets the maximum length of the column.
        /// 
        public int MaxLength { get; private set; }
        /// 
        /// Gets the default value of the column.
        /// 
        public IList DefaultValue
        {
            get { return this.defaultValue; }
        }
        /// 
        /// Gets the column options.
        /// 
        public ColumndefGrbit Grbit { get; private set; }
        /// 
        /// Returns a  that represents the current .
        /// 
        /// 
        /// A  that represents the current .
        /// 
        public override string ToString()
        {
            return this.Name;
        }
    }
}