/*********************************************************************/ /* */ /* AgentService Framework */ /* www.agentservice.it */ /* */ /* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */ /* GNU Lesser General Public License */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation, */ /* version 2.1 of the License. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the */ /* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ /* Boston, MA 02111-1307, USA. */ /* */ /*********************************************************************/ using System; using System.Collections.Specialized; using AgentService.Platform.Modules; namespace AgentService.Platform.Configuration { /// /// Class InstallationData. Holds installation information /// public class InstallationData { /// /// Base dir path for the AgentService platform /// protected string baseDirPath; /// /// Gets, sets the base dir path for the AgentService /// platform /// public string BaseDirPath { get { return this.baseDirPath; } set { if (this.bUpdating == false) throw new InvalidOperationException("Properties can be modified only in the updating phase"); this.baseDirPath = value; } } /// /// Repository file name /// protected string repositoryFile; /// /// Gets, sets the base dir path for the AgentService /// platform /// public string RepositoryFile { get { return this.repositoryFile; } set { if (this.bUpdating == false) throw new InvalidOperationException("Properties can be modified only in the updating phase"); this.repositoryFile = value; } } /// /// /// private PlatformDescription descr; /// /// Gets, sets the platform description /// public PlatformDescription PlatformDescription { get { return this.descr; } set { if (this.bUpdating == false) throw new InvalidOperationException("Properties can be modified only in the updating phase"); this.descr = value; } } /// /// error flag. /// private bool bHasErrors; /// /// Indicates whether the configuration is consistent. /// public bool HasErrors { get { return this.bHasErrors; } } /// /// error message /// private string errorMessage; /// /// Gets the error message /// public string ErrorMessage { get { return this.errorMessage; } set { if (this.bUpdating == false) throw new InvalidOperationException("Properties can be modified only in the updating phase"); this.errorMessage = value; } } /// /// true while the installation data are update. /// bUpdating is set to true by calling BeginUpdate, /// while is set to false by calling EndUpdate /// private bool bUpdating; /// /// Gets true while the installation data are updated /// public bool IsUpdating { get { return this.bUpdating; } } /// /// Info about the storage module. /// protected ModuleInfo storageModule; /// /// Gets, sets the storage module loading information. /// public ModuleInfo Storage { get { return this.storageModule; } set { if (this.bUpdating == false) { throw new InvalidOperationException("Properties can be modified only in the reading phase"); } this.storageModule = value; } } /// /// Info about the messaging module. /// protected ModuleInfo messagingModule; /// /// Gets, sets the messaging module loading information. /// public ModuleInfo Messaging { get { return this.messagingModule; } set { if (this.bUpdating == false) { throw new InvalidOperationException("Properties can be modified only in the reading phase"); } this.messagingModule = value; } } /// /// Info about the persistence module. /// protected ModuleInfo persistenceModule; /// /// Gets, sets the persistence module loading information. /// public ModuleInfo Persistence { get { return this.persistenceModule; } set { if (this.bUpdating == false) { throw new InvalidOperationException("Properties can be modified only in the reading phase"); } this.persistenceModule = value; } } /// /// Info about the logging module. /// protected ModuleInfo loggingModule; /// /// Gets, sets the logging module loading information. /// public ModuleInfo Logging { get { return this.loggingModule; } set { if (this.bUpdating == false) { throw new InvalidOperationException("Properties can be modified only in the reading phase"); } this.loggingModule = value; } } /// /// Additional modules information. /// private ModuleInfo[] additionalModules; /// /// Gets, sets the loading information about the additional modules. /// public ModuleInfo[] AdditionalModules { get { return this.additionalModules; } set { if (this.bUpdating == false) { throw new InvalidOperationException("Properties can be modified only in the reading phase"); } this.additionalModules = value; } } /// /// dictionary of additional properties /// protected StringDictionary properties; /// /// Gets, sets the dictionary of additional /// properties. /// public StringDictionary Properties { set { if (this.bUpdating == false) { throw new InvalidOperationException("Properties can be modified only in the reading phase"); } this.properties = value; } get { return this.properties; } } /// /// Begins the update process, and sets the Updating property to true. /// public void BeginUpdate() { this.bUpdating = true; } /// /// Terminates the update process and sets the Updating property to false. /// public void EndUpdate() { this.bUpdating = false; } /// /// Sets the HasErrors property to true during updating. Calling this method /// outside the updating process will throw an InvalidOperation exception. /// public void SetError() { if (this.bUpdating) this.bHasErrors = true; else throw new InvalidOperationException("Cannot notify errors while installation data are not in the updating phase."); } /// /// Clears the HasErrors flag. /// public void ResetError() { this.bHasErrors = false; } } /// /// Class InstallManager. Base abstract type for InstallManager types. /// Basicly reads and writes installation files from and to a file. /// public abstract class InstallManager { /// /// Gets the information message about the last operation /// public virtual string InfoMessage { get { return null; } } /// /// Gets the selected installation file. /// public virtual string InstallationFile { get { return null; } } /// /// Gets, sets the default configuration file /// public virtual string ConfigurationFile { get { return null; } set { } } /// /// Gets, sets the description of the platform /// public virtual PlatformDescription PlatformDescription { get { return null; } set { } } /// /// Reads the installation file and constructs the corresponding /// InstallationData object. /// /// InstallationData object public virtual InstallationData Read() { return null; } /// /// Writes the default configuration file. /// public virtual bool GenerateDefaultConfigurationFile(InstallationData inst) { return true; } } }