| 1 | /* |
|---|
| 2 | * $Id$ |
|---|
| 3 | * Copyright 2008-2011 The Eraser Project |
|---|
| 4 | * Original Author: Joel Low <lowjoel@users.sourceforge.net> |
|---|
| 5 | * Modified By: |
|---|
| 6 | * |
|---|
| 7 | * This file is part of Eraser. |
|---|
| 8 | * |
|---|
| 9 | * Eraser is free software: you can redistribute it and/or modify it under the |
|---|
| 10 | * terms of the GNU General Public License as published by the Free Software |
|---|
| 11 | * Foundation, either version 3 of the License, or (at your option) any later |
|---|
| 12 | * version. |
|---|
| 13 | * |
|---|
| 14 | * Eraser is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 15 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
|---|
| 16 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|---|
| 17 | * |
|---|
| 18 | * A copy of the GNU General Public License can be found at |
|---|
| 19 | * <http://www.gnu.org/licenses/>. |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | using System; |
|---|
| 23 | using System.Collections.Generic; |
|---|
| 24 | using System.Linq; |
|---|
| 25 | using System.Text; |
|---|
| 26 | |
|---|
| 27 | using Eraser.Util; |
|---|
| 28 | using Eraser.Plugins.ExtensionPoints; |
|---|
| 29 | |
|---|
| 30 | namespace Eraser.Plugins.Registrars |
|---|
| 31 | { |
|---|
| 32 | /// <summary> |
|---|
| 33 | /// Class managing all the erasure methods. This class pairs GUIDs with constructor |
|---|
| 34 | /// prototypes, and when an instance of the erasure method is required, a new |
|---|
| 35 | /// instance is created. This is unique to erasure methods since the other managers |
|---|
| 36 | /// do not have run-time equivalents; they all are compile-time. |
|---|
| 37 | /// </summary> |
|---|
| 38 | public class ErasureMethodRegistrar : Registrar<ErasureMethod> |
|---|
| 39 | { |
|---|
| 40 | #region Default Erasure method |
|---|
| 41 | private class DefaultMethod : ErasureMethod |
|---|
| 42 | { |
|---|
| 43 | public DefaultMethod() |
|---|
| 44 | { |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | public override string Name |
|---|
| 48 | { |
|---|
| 49 | get { return S._("(default)"); } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | public override int Passes |
|---|
| 53 | { |
|---|
| 54 | get { return 0; } |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | public override Guid Guid |
|---|
| 58 | { |
|---|
| 59 | get { return Guid.Empty; } |
|---|
| 60 | } |
|---|
| 61 | |
|---|
| 62 | public override long CalculateEraseDataSize(ICollection<StreamInfo> paths, long targetSize) |
|---|
| 63 | { |
|---|
| 64 | throw new InvalidOperationException("The DefaultMethod class should never " + |
|---|
| 65 | "be used and should instead be replaced before execution!"); |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | public override void Erase(Stream strm, long erasureLength, Prng prng, |
|---|
| 69 | ErasureMethod.ErasureMethodProgressFunction callback) |
|---|
| 70 | { |
|---|
| 71 | throw new InvalidOperationException("The DefaultMethod class should never " + |
|---|
| 72 | "be used and should instead be replaced before execution!"); |
|---|
| 73 | } |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | /// <summary> |
|---|
| 77 | /// A dummy method placeholder used for representing the default erase |
|---|
| 78 | /// method. Do not use this variable when trying to call the erase function, |
|---|
| 79 | /// this is just a placeholder and will throw a InvalidOperationException. |
|---|
| 80 | /// </summary> |
|---|
| 81 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] |
|---|
| 82 | public static readonly ErasureMethod Default = new DefaultMethod(); |
|---|
| 83 | #endregion |
|---|
| 84 | } |
|---|
| 85 | } |
|---|