// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org/?p=license&r=2.4
// ****************************************************************
using System;
namespace NUnit.Util
{
public delegate void SettingsEventHandler( object sender, SettingsEventArgs args );
public class SettingsEventArgs : EventArgs
{
private string settingName;
public SettingsEventArgs( string settingName )
{
this.settingName = settingName;
}
public string SettingName
{
get { return settingName; }
}
}
///
/// The ISettings interface is used to access all user
/// settings and options.
///
public interface ISettings
{
event SettingsEventHandler Changed;
///
/// Load a setting from the storage.
///
/// Name of the setting to load
/// Value of the setting or null
object GetSetting( string settingName );
///
/// Load a setting from the storage or return a default value
///
/// Name of the setting to load
/// Value to return if the setting is missing
/// Value of the setting or the default value
object GetSetting( string settingName, object defaultValue );
///
/// Load an integer setting from the storage or return a default value
///
/// Name of the setting to load
/// Value to return if the setting is missing
/// Value of the setting or the default value
int GetSetting( string settingName, int defaultValue );
///
/// Load a boolean setting or return a default value
///
/// Name of setting to load
/// Value to return if the setting is missing
/// Value of the setting or the default value
bool GetSetting( string settingName, bool defaultValue );
///
/// Load a string setting from the storage or return a default value
///
/// Name of the setting to load
/// Value to return if the setting is missing
/// Value of the setting or the default value
string GetSetting( string settingName, string defaultValue );
///
/// Load an enum setting from the storage or return a default value
///
/// Name of the setting to load
/// Value to return if the setting is missing
/// Value of the setting or the default value
System.Enum GetSetting( string settingName, System.Enum defaultValue );
///
/// Remove a setting from the storage
///
/// Name of the setting to remove
void RemoveSetting( string settingName );
///
/// Remove an entire group of settings from the storage
///
/// Name of the group to remove
void RemoveGroup( string groupName );
///
/// Save a setting in the storage
///
/// Name of the setting to save
/// Value to be saved
void SaveSetting( string settingName, object settingValue );
}
}