//-----------------------------------------------------------------------
//
// 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_RSTMAP 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_RSTMAP
{
///
/// The old name/path of the database. Can be null if it is unchanged.
///
public IntPtr szDatabaseName;
///
/// The current name/path of the database. Must not be null.
///
public IntPtr szNewDatabaseName;
///
/// Free the string memory.
///
public void FreeHGlobal()
{
LibraryHelpers.MarshalFreeHGlobal(this.szDatabaseName);
LibraryHelpers.MarshalFreeHGlobal(this.szNewDatabaseName);
}
}
///
/// Enables the remapping of database file paths that are stored in the transaction logs during recovery.
///
[SuppressMessage(
"Microsoft.StyleCop.CSharp.NamingRules",
"SA1300:ElementMustBeginWithUpperCaseLetter",
Justification = "This should match the unmanaged API, which isn't capitalized.")]
[Serializable]
public class JET_RSTMAP : IContentEquatable, IDeepCloneable
{
///
/// The old name/path of the database. Can be null if it is unchanged.
///
private string databaseName;
///
/// The current name/path of the database. Must not be null.
///
private string newDatabaseName;
///
/// Gets or sets the old name/path of the database. Can be null if it is unchanged.
///
public string szDatabaseName
{
[DebuggerStepThrough]
get { return this.databaseName; }
set { this.databaseName = value; }
}
///
/// Gets or sets the current name/path of the database. Must not be null.
///
public string szNewDatabaseName
{
[DebuggerStepThrough]
get { return this.newDatabaseName; }
set { this.newDatabaseName = value; }
}
///
/// Returns a that represents the current .
///
///
/// A that represents the current .
///
public override string ToString()
{
return string.Format(
CultureInfo.InvariantCulture,
"JET_RSTINFO(szDatabaseName={0},szNewDatabaseName={1})",
this.szDatabaseName,
this.szNewDatabaseName);
}
///
/// 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_RSTMAP other)
{
if (null == other)
{
return false;
}
return string.Equals(this.szDatabaseName, other.szDatabaseName, StringComparison.OrdinalIgnoreCase)
&& string.Equals(this.szNewDatabaseName, other.szNewDatabaseName, StringComparison.OrdinalIgnoreCase);
}
///
/// Returns a deep copy of the object.
///
/// A deep copy of the object.
public JET_RSTMAP DeepClone()
{
return (JET_RSTMAP)this.MemberwiseClone();
}
///
/// Get a native version of this managed structure.
///
/// A native version of this object.
internal NATIVE_RSTMAP GetNativeRstmap()
{
return new NATIVE_RSTMAP
{
// Don't pin this memory -- these structures are used by JetInit3,
// which can run for a long time and we don't want to fragment the
// heap. We do have to remember to free the memory though.
szDatabaseName = LibraryHelpers.MarshalStringToHGlobalUni(this.szDatabaseName),
szNewDatabaseName = LibraryHelpers.MarshalStringToHGlobalUni(this.szNewDatabaseName),
};
}
}
}