//-----------------------------------------------------------------------
//
// 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_RETINFO 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_RECPOS
{
///
/// Size of NATIVE_RECPOS structures.
///
public static readonly int Size = Marshal.SizeOf(typeof(NATIVE_RECPOS));
///
/// Size of this structure.
///
public uint cbStruct;
///
/// Approximate number of index entries less than the key.
///
public uint centriesLT;
///
/// Approximate number of entries in the index range.
///
public uint centriesInRange;
///
/// Approximate number of entries in the index.
///
public uint centriesTotal;
}
///
/// Represents a fractional position within an index. This is used by JetGotoPosition
/// and JetGetRecordPosition.
///
[SuppressMessage(
"Microsoft.StyleCop.CSharp.NamingRules",
"SA1300:ElementMustBeginWithUpperCaseLetter",
Justification = "This should match the unmanaged API, which isn't capitalized.")]
[Serializable]
public sealed class JET_RECPOS : IContentEquatable, IDeepCloneable
{
///
/// The number of entries before the key.
///
private long entriesBeforeKey;
///
/// Total number of entries.
///
private long totalEntries;
///
/// Gets or sets the approximate number of index entries less than the key.
///
public long centriesLT
{
[DebuggerStepThrough]
get { return this.entriesBeforeKey; }
set { this.entriesBeforeKey = value; }
}
///
/// Gets or sets the approximate number of entries in the index.
///
public long centriesTotal
{
[DebuggerStepThrough]
get { return this.totalEntries; }
set { this.totalEntries = value; }
}
///
/// Returns a deep copy of the object.
///
/// A deep copy of the object.
public JET_RECPOS DeepClone()
{
return (JET_RECPOS)this.MemberwiseClone();
}
///
/// Generate a string representation of the instance.
///
/// The structure as a string.
public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "JET_RECPOS({0}/{1})", this.entriesBeforeKey, this.totalEntries);
}
///
/// 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_RECPOS other)
{
if (null == other)
{
return false;
}
return this.entriesBeforeKey == other.entriesBeforeKey && this.totalEntries == other.totalEntries;
}
///
/// Get a NATIVE_RECPOS structure representing the object.
///
/// A NATIVE_RECPOS whose members match the class.
internal NATIVE_RECPOS GetNativeRecpos()
{
var recpos = new NATIVE_RECPOS();
recpos.cbStruct = checked((uint)NATIVE_RECPOS.Size);
recpos.centriesLT = checked((uint)this.centriesLT);
recpos.centriesTotal = checked((uint)this.centriesTotal);
return recpos;
}
///
/// Sets the fields of the object from a NATIVE_RECPOS structure.
///
/// The NATIVE_RECPOS which will be used to set the fields.
internal void SetFromNativeRecpos(NATIVE_RECPOS value)
{
this.centriesLT = checked((int)value.centriesLT);
this.centriesTotal = checked((int)value.centriesTotal);
}
}
}