#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig /************************************************************************************ ' ' Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole ' Copyright 2000-2002 Philip A. Craig ' ' This software is provided 'as-is', without any express or implied warranty. In no ' event will the authors be held liable for any damages arising from the use of this ' software. ' ' Permission is granted to anyone to use this software for any purpose, including ' commercial applications, and to alter it and redistribute it freely, subject to the ' following restrictions: ' ' 1. The origin of this software must not be misrepresented; you must not claim that ' you wrote the original software. If you use this software in a product, an ' acknowledgment (see the following) in the product documentation is required. ' ' Portions Copyright 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole ' or Copyright 2000-2002 Philip A. Craig ' ' 2. Altered source versions must be plainly marked as such, and must not be ' misrepresented as being the original software. ' ' 3. This notice may not be removed or altered from any source distribution. ' '***********************************************************************************/ #endregion namespace NUnit.Util { using System; using System.IO; /// /// Abstract class representing a hierarchical storage used to hold /// application settings. The actual implementation is left to /// derived classes, and may be based on the registry, isolated /// storage or any other mechanism. /// public abstract class SettingsStorage : IDisposable { #region Instance Variables /// /// The name of this storage /// private string storageName; /// /// The parent storage containing this storage /// private SettingsStorage parentStorage; #endregion #region Construction and Disposal /// /// Construct a SettingsStorage under a parent storage /// /// Name of the storage /// The parent which contains the new storage public SettingsStorage( string storageName, SettingsStorage parentStorage ) { this.storageName = storageName; this.parentStorage = parentStorage; } /// /// Dispose of resources held by this storage /// public abstract void Dispose(); #endregion #region Properties /// /// The number of settings in this group /// public abstract int SettingsCount { get; } /// /// The name of the storage /// public string StorageName { get { return storageName; } } /// /// The storage that contains this one /// public SettingsStorage ParentStorage { get { return parentStorage; } } #endregion #region Methods /// /// Find out if a substorage exists /// /// Name of the child storage /// True if the storage exists public abstract bool ChildStorageExists( string name ); /// /// Create a child storage of the same type /// /// Name of the child storage /// New child storage public abstract SettingsStorage MakeChildStorage( string name ); /// /// Clear all settings from the storage - empty storage remains /// public abstract void Clear(); /// /// Load a setting from the storage. /// /// Name of the setting to load /// Value of the setting or null public abstract object LoadSetting( string settingName ); /// /// Load an integer setting from the storage /// /// Name of the setting to load /// Value of the setting or null public abstract int LoadIntSetting( string settingName ); /// /// Load a string setting from the storage /// /// Name of the setting to load /// Value of the setting or null public abstract string LoadStringSetting( 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 public abstract object LoadSetting( 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 public abstract int LoadIntSetting( string settingName, int 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 public abstract string LoadStringSetting( string settingName, string defaultValue ); /// /// Remove a setting from the storage /// /// Name of the setting to remove public abstract void RemoveSetting( string settingName ); /// /// Save a setting in the storage /// /// Name of the setting to save /// Value to be saved public abstract void SaveSetting( string settingName, object settingValue ); #endregion } }