/* * $Id$ * Copyright 2008 The Eraser Project * Original Author: Joel Low * Modified By: * * This file is part of Eraser. * * Eraser is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * Eraser 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 General Public License for more details. * * A copy of the GNU General Public License can be found at * . */ using System; using System.Collections.Generic; using System.Text; using System.Runtime.Serialization; namespace Eraser.Manager { /// /// The library instance which initializes and cleans up data required for the /// library to function. /// public class ManagerLibrary : IDisposable { public ManagerLibrary(SettingsManager settings) { if (Instance != null) throw new InvalidOperationException("Only one ManagerLibrary instance can " + "exist at any one time"); Instance = this; SettingsManager = settings; EntropySourceManager = new EntropySourceManager(); PRNGManager = new PrngManager(); ErasureMethodManager = new ErasureMethodManager(); FileSystemManager = new FileSystemManager(); Host = new Plugin.DefaultHost(); Host.Load(); } ~ManagerLibrary() { Dispose(false); } protected virtual void Dispose(bool disposing) { if (disposing) { EntropySourceManager.Poller.Abort(); Host.Dispose(); SettingsManager.Save(); } SettingsManager = null; Instance = null; } public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } /// /// The global library instance. /// public static ManagerLibrary Instance { get; private set; } /// /// The global instance of the EntropySource Manager /// internal EntropySourceManager EntropySourceManager; /// /// The global instance of the PRNG Manager. /// internal PrngManager PRNGManager; /// /// The global instance of the Erasure method manager. /// internal ErasureMethodManager ErasureMethodManager; /// /// The global instance of the File System manager. /// internal FileSystemManager FileSystemManager; /// /// Global instance of the Settings manager. /// public SettingsManager SettingsManager { get; set; } /// /// Gets the settings object representing the settings for the Eraser /// Manager. This is just shorthand for the local classes. /// public static ManagerSettings Settings { get { if (settingsInstance == null) settingsInstance = new ManagerSettings(); return settingsInstance; } } /// /// The singleton instance for . /// private static ManagerSettings settingsInstance; /// /// The global instance of the Plugin host. /// internal Plugin.DefaultHost Host; } }