//----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. // //----------------------------------------------------------------------- namespace Microsoft.Isam.Esent.Interop { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime.InteropServices; /// /// The native version of the JET_CONDITIONALCOLUMN 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_CONDITIONALCOLUMN { /// /// Size of the structure. /// public uint cbStruct; /// /// Name of the column. /// public IntPtr szColumnName; /// /// Conditional column option. /// public uint grbit; } /// /// Defines how conditional indexing is performed for a given index. A /// conditional index contains an index entry for only those rows that /// match the specified condition. However, the conditional column is not /// part of the index's key, it only controls the presence of the index entry. /// [SuppressMessage( "Microsoft.StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "This should match the unmanaged API, which isn't capitalized.")] [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "This should match the unmanaged API, which isn't capitalized.")] [Serializable] public sealed class JET_CONDITIONALCOLUMN : IContentEquatable, IDeepCloneable { /// /// Column name. /// private string columnName; /// /// Conditional column option. /// private ConditionalColumnGrbit option; /// /// Gets or sets the name of the conditional column. /// public string szColumnName { [DebuggerStepThrough] get { return this.columnName; } set { this.columnName = value; } } /// /// Gets or sets the options for the conditional index. /// public ConditionalColumnGrbit grbit { [DebuggerStepThrough] get { return this.option; } set { this.option = value; } } /// /// Returns a deep copy of the object. /// /// A deep copy of the object. public JET_CONDITIONALCOLUMN DeepClone() { return (JET_CONDITIONALCOLUMN)this.MemberwiseClone(); } /// /// Generate a string representation of the instance. /// /// The structure as a string. public override string ToString() { return string.Format( CultureInfo.InvariantCulture, "JET_CONDITIONALCOLUMN({0}:{1})", this.columnName, this.option); } /// /// Returns a value indicating whether this instance is equal /// to another instance. /// /// An instance to compare with this instance. /// True if the two instances are equal. public bool ContentEquals(JET_CONDITIONALCOLUMN other) { if (null == other) { return false; } return this.columnName == other.columnName && this.option == other.option; } /// /// Gets the NATIVE_CONDITIONALCOLUMN version of this object. /// /// A NATIVE_CONDITIONALCOLUMN for this object. internal NATIVE_CONDITIONALCOLUMN GetNativeConditionalColumn() { var native = new NATIVE_CONDITIONALCOLUMN(); native.cbStruct = (uint)Marshal.SizeOf(typeof(NATIVE_CONDITIONALCOLUMN)); native.grbit = (uint)this.grbit; return native; } } }