//-----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.
//
//-----------------------------------------------------------------------
namespace Microsoft.Database.Isam.Config
{
using System;
using System.Collections.Generic;
///
/// Merge rules for merging config sets.
///
public enum MergeRules
{
///
/// Throw an exception if a merge causes a parameter to be overwritten with a different value in the destination config set.
///
ThrowOnConflicts = 0,
///
/// Overwrite destination config set.
///
Overwrite,
///
/// Keep existing values of the destination config set intact while performing the merge.
///
KeepExisting,
}
///
/// Interface definition for a config set.
///
public interface IConfigSet : IEnumerable>
{
///
/// Gets a particular config parameter's value.
///
/// The parameter to get.
/// The requested parameter's value.
object this[int key] { get; }
///
/// Gets a particular config parameter's value.
///
/// The parameter to get.
/// The requested parameter's value.
/// true if the value was found, false otherwise.
bool TryGetValue(int key, out object value);
///
/// Merges two config sets into one and throws an exception if there are any conflicts.
///
/// The MergeSource config set to user.
void Merge(IConfigSet source);
///
/// Merges two config sets into one.
///
/// The MergeSource config set to user.
/// The merge rule to use.
void Merge(IConfigSet source, MergeRules mergeRule);
}
///
/// Represents exceptions thrown while merging two config sets.
///
public sealed class ConfigSetMergeException : Exception
{
///
/// Initializes a new instance of the ConfigSetMergeException class.
///
/// The MergeSource config set.
/// The destination config set.
/// The exception message.
public ConfigSetMergeException(IConfigSet mergeSource, IConfigSet mergeDest, string message) : this(mergeSource, mergeDest, message, null)
{
}
///
/// Initializes a new instance of the ConfigSetMergeException class.
///
/// The MergeSource config set.
/// The destination config set.
/// The exception message.
/// The inner exception.
public ConfigSetMergeException(IConfigSet mergeSource, IConfigSet mergeDest, string message, Exception inner) : base(message, inner)
{
this.MergeSource = mergeSource;
this.MergeDest = mergeDest;
}
///
/// Gets the MergeSource config set used during the merge operation.
///
public IConfigSet MergeSource { get; private set; }
///
/// Gets the destination config set used during the merge operation.
///
public IConfigSet MergeDest { get; private set; }
}
}