//-----------------------------------------------------------------------
//
// 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_INDEXRANGE 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_INDEXRANGE
{
///
/// Size of the structure.
///
public uint cbStruct;
///
/// Cursor containing the index range.
///
public IntPtr tableid;
///
/// Index range options.
///
public uint grbit;
///
/// Create a NATIVE_INDEXRANGE from a cursor.
///
/// The cursor containing the index range.
/// A new NATIVE_INDEXRANGE on the cursor.
public static NATIVE_INDEXRANGE MakeIndexRangeFromTableid(JET_TABLEID tableid)
{
var s = new NATIVE_INDEXRANGE
{
tableid = tableid.Value,
grbit = (uint)IndexRangeGrbit.RecordInIndex,
};
s.cbStruct = (uint)Marshal.SizeOf(typeof(NATIVE_INDEXRANGE));
return s;
}
}
///
/// Identifies an index range when it is used with the JetIntersectIndexes function.
///
[SuppressMessage(
"Microsoft.StyleCop.CSharp.NamingRules",
"SA1300:ElementMustBeginWithUpperCaseLetter",
Justification = "This should match the unmanaged API, which isn't capitalized.")]
public class JET_INDEXRANGE : IContentEquatable, IDeepCloneable
{
///
/// Initializes a new instance of the JET_INDEXRANGE class.
///
public JET_INDEXRANGE()
{
// set the grbit to the only valid value
this.grbit = IndexRangeGrbit.RecordInIndex;
}
///
/// Gets or sets the cursor containing the index range. The cursor should have an
/// index range set with JetSetIndexRange.
///
public JET_TABLEID tableid { get; set; }
///
/// Gets or sets the indexrange option.
///
public IndexRangeGrbit grbit { get; set; }
///
/// Returns a deep copy of the object.
///
/// A deep copy of the object.
public JET_INDEXRANGE DeepClone()
{
return (JET_INDEXRANGE)this.MemberwiseClone();
}
///
/// Returns a that represents the current .
///
///
/// A that represents the current .
///
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "JET_INDEXRANGE(0x{0:x},{1})", this.tableid.Value, this.grbit);
}
///
/// 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_INDEXRANGE other)
{
if (null == other)
{
return false;
}
return this.tableid == other.tableid
&& this.grbit == other.grbit;
}
///
/// Get a NATIVE_INDEXRANGE structure representing the object.
///
/// A NATIVE_INDEXRANGE whose members match the class.
internal NATIVE_INDEXRANGE GetNativeIndexRange()
{
var indexrange = new NATIVE_INDEXRANGE();
indexrange.cbStruct = (uint)Marshal.SizeOf(typeof(NATIVE_INDEXRANGE));
indexrange.tableid = this.tableid.Value;
indexrange.grbit = (uint)this.grbit;
return indexrange;
}
}
}