//-----------------------------------------------------------------------
//
// 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_UNICODEINDEX 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_UNICODEINDEX
{
///
/// The LCID to be used when normalizing unicode data.
///
public uint lcid;
///
/// The flags for LCMapString.
///
public uint dwMapFlags;
}
///
/// Customizes how Unicode data gets normalized when an index is created over a Unicode column.
///
[SuppressMessage(
"Microsoft.StyleCop.CSharp.NamingRules",
"SA1300:ElementMustBeginWithUpperCaseLetter",
Justification = "This should match the unmanaged API, which isn't capitalized.")]
[Serializable]
public sealed partial class JET_UNICODEINDEX : IContentEquatable, IDeepCloneable
{
///
/// The LCID to be used when normalizing unicode data.
///
private int localeId;
///
/// The LocaleName to be used when normalizing unicode data.
///
private string localeName;
///
/// Sets the flags to be used with LCMapString when normalizing unicode data.
///
private uint mapStringFlags;
///
/// Gets or sets the LCID to be used when normalizing unicode data.
///
public int lcid
{
[DebuggerStepThrough]
get { return this.localeId; }
set { this.localeId = value; }
}
///
/// Gets or sets the LocaleName to be used when normalizing unicode data.
///
public string szLocaleName
{
[DebuggerStepThrough]
get { return this.localeName; }
set { this.localeName = value; }
}
///
/// Gets or sets the flags to be used with LCMapString when normalizing unicode data.
///
[CLSCompliant(false)]
public uint dwMapFlags
{
[DebuggerStepThrough]
get { return this.mapStringFlags; }
set { this.mapStringFlags = value; }
}
///
/// Returns a deep copy of the object.
///
/// A deep copy of the object.
public JET_UNICODEINDEX DeepClone()
{
return (JET_UNICODEINDEX)this.MemberwiseClone();
}
///
/// Generate a string representation of the instance.
///
/// The structure as a string.
public override string ToString()
{
return string.Format(
CultureInfo.InvariantCulture,
"JET_UNICODEINDEX({0}:{1}:0x{2:X})",
this.localeId,
this.localeName,
this.mapStringFlags);
}
///
/// 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_UNICODEINDEX other)
{
if (null == other)
{
return false;
}
return this.localeId == other.localeId && this.mapStringFlags == other.mapStringFlags && string.Compare(this.localeName, other.localeName, StringComparison.Ordinal) == 0;
}
///
/// Gets the native version of this object.
///
/// The native version of this object.
internal NATIVE_UNICODEINDEX GetNativeUnicodeIndex()
{
if (!string.IsNullOrEmpty(this.localeName))
{
throw new ArgumentException("localeName was specified, but this version of the API does not accept locale names. Use LCIDs or a different API.");
}
var native = new NATIVE_UNICODEINDEX
{
lcid = (uint)this.lcid,
dwMapFlags = this.dwMapFlags,
};
return native;
}
}
}