Changeset 1792


Ignore:
Timestamp:
2/10/2010 6:32:45 AM (4 years ago)
Author:
lowjoel
Message:

Implemented an IRegistrar interface for all registrars, and an IRegisterable interface for all classes which need to be registered with IRegistrar, and migrated the Entropy and Erasure Method classes to the new interfaces. Addresses #276: Implement Eraser Registrar Interface

Location:
branches/eraser6/CodeReview
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/CustomMethodEditorForm.cs

    r1681 r1792  
    3333namespace Eraser.DefaultPlugins 
    3434{ 
    35     public partial class CustomMethodEditorForm : Form 
     35    internal partial class CustomMethodEditorForm : Form 
    3636    { 
    3737        public CustomMethodEditorForm() 
  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/ErasureMethods/Custom.cs

    r1681 r1792  
    5656            { 
    5757                CustomErasureMethod method = methods[guid]; 
    58                 ErasureMethodManager.Register(new EraseCustom(method), new object[] { method }); 
     58                ManagerLibrary.Instance.ErasureMethodManager.Add(new EraseCustom(method)); 
    5959            } 
    6060        } 
     
    8787    /// </summary> 
    8888    [Serializable] 
    89     public class CustomErasureMethod : ISerializable 
     89    internal class CustomErasureMethod : ISerializable 
    9090    { 
    9191        public CustomErasureMethod() 
  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/ErasureMethods/FirstLast16KB.cs

    r1769 r1792  
    4040                //Try to retrieve the set erasure method 
    4141                if (DefaultPlugin.Settings.FL16Method != Guid.Empty) 
    42                     method = ErasureMethodManager.GetInstance( 
    43                         DefaultPlugin.Settings.FL16Method); 
     42                    method = ManagerLibrary.Instance.ErasureMethodManager[ 
     43                        DefaultPlugin.Settings.FL16Method]; 
    4444                else if (ManagerLibrary.Settings.DefaultFileErasureMethod != Guid) 
    45                     method = ErasureMethodManager.GetInstance( 
    46                         ManagerLibrary.Settings.DefaultFileErasureMethod); 
     45                    method = ManagerLibrary.Instance.ErasureMethodManager[ 
     46                        ManagerLibrary.Settings.DefaultFileErasureMethod]; 
    4747                else 
    48                     method = ErasureMethodManager.GetInstance(new Gutmann().Guid); 
     48                    method = ManagerLibrary.Instance.ErasureMethodManager[new Gutmann().Guid]; 
    4949            } 
    5050            catch (ErasureMethodNotFoundException) 
  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/Plugin.cs

    r1681 r1792  
    3838 
    3939            //Then register the erasure methods et al. 
    40             ErasureMethodManager.Register(new Gutmann());               //35 passes 
    41             ErasureMethodManager.Register(new GutmannLite());           //10 passes 
    42             ErasureMethodManager.Register(new DoD_EcE());               //7 passes 
    43             ErasureMethodManager.Register(new RCMP_TSSIT_OPS_II());     //7 passes 
    44             ErasureMethodManager.Register(new Schneier());              //7 passes 
    45             ErasureMethodManager.Register(new VSITR());                 //7 passes 
    46             ErasureMethodManager.Register(new DoD_E());                 //3 passes 
    47             ErasureMethodManager.Register(new HMGIS5Enhanced());        //3 passes 
    48             ErasureMethodManager.Register(new USAF5020());              //3 passes 
    49             ErasureMethodManager.Register(new USArmyAR380_19());        //3 passes 
    50             ErasureMethodManager.Register(new GOSTP50739());            //2 passes 
    51             ErasureMethodManager.Register(new HMGIS5Baseline());        //1 pass 
    52             ErasureMethodManager.Register(new Pseudorandom());          //1 pass 
     40            ManagerLibrary.Instance.ErasureMethodManager.Add(new Gutmann());            //35 passes 
     41            ManagerLibrary.Instance.ErasureMethodManager.Add(new GutmannLite());        //10 passes 
     42            ManagerLibrary.Instance.ErasureMethodManager.Add(new DoD_EcE());            //7 passes 
     43            ManagerLibrary.Instance.ErasureMethodManager.Add(new RCMP_TSSIT_OPS_II());  //7 passes 
     44            ManagerLibrary.Instance.ErasureMethodManager.Add(new Schneier());           //7 passes 
     45            ManagerLibrary.Instance.ErasureMethodManager.Add(new VSITR());              //7 passes 
     46            ManagerLibrary.Instance.ErasureMethodManager.Add(new DoD_E());              //3 passes 
     47            ManagerLibrary.Instance.ErasureMethodManager.Add(new HMGIS5Enhanced());     //3 passes 
     48            ManagerLibrary.Instance.ErasureMethodManager.Add(new USAF5020());           //3 passes 
     49            ManagerLibrary.Instance.ErasureMethodManager.Add(new USArmyAR380_19());     //3 passes 
     50            ManagerLibrary.Instance.ErasureMethodManager.Add(new GOSTP50739());         //2 passes 
     51            ManagerLibrary.Instance.ErasureMethodManager.Add(new HMGIS5Baseline());     //1 pass 
     52            ManagerLibrary.Instance.ErasureMethodManager.Add(new Pseudorandom());       //1 pass 
    5353            EraseCustom.RegisterAll(); 
    54             ErasureMethodManager.Register(new FirstLast16KB()); 
     54            ManagerLibrary.Instance.ErasureMethodManager.Add(new FirstLast16KB()); 
    5555 
    5656            PrngManager.Register(new RngCrypto()); 
  • branches/eraser6/CodeReview/Eraser.DefaultPlugins/SettingsForm.cs

    r1681 r1792  
    4242 
    4343            //Populate the list of erasure passes, except the FL16KB. 
    44             foreach (ErasureMethod method in ErasureMethodManager.Items.Values) 
     44            foreach (ErasureMethod method in ManagerLibrary.Instance.ErasureMethodManager) 
    4545                if (method.Guid != new Guid("{0C2E07BF-0207-49a3-ADE8-46F9E1499C01}")) 
    4646                    fl16MethodCmb.Items.Add(method); 
     
    161161            { 
    162162                customMethods.Remove(guid); 
    163                 ErasureMethodManager.Unregister(guid); 
     163                ManagerLibrary.Instance.ErasureMethodManager.Remove(guid); 
    164164            } 
    165165 
     
    168168            { 
    169169                customMethods.Add(method.Guid, method); 
    170                 ErasureMethodManager.Register(new EraseCustom(method), new object[] { method }); 
     170                ManagerLibrary.Instance.ErasureMethodManager.Add(new EraseCustom(method)); 
    171171            } 
    172172 
  • branches/eraser6/CodeReview/Eraser.Manager/EntropySource.cs

    r1681 r1792  
    4343    /// the EntropyPoller class. 
    4444    /// </summary> 
    45     public abstract class EntropySource 
     45    public abstract class EntropySource : IRegisterable 
    4646    { 
    4747        /// <summary> 
     
    126126    /// available. Plugins could register their entropy sources via this class. 
    127127    /// </summary> 
    128     public class EntropySourceManager 
     128    public class EntropySourceRegistrar : Registrar<EntropySource> 
    129129    { 
    130130        /// <summary> 
    131131        /// Constructor. 
    132132        /// </summary> 
    133         public EntropySourceManager() 
    134         { 
    135             entropyThread.AddEntropySource(new KernelEntropySource()); 
    136         } 
    137  
    138         /// <summary> 
    139         /// Retrieves all currently registered erasure methods. 
    140         /// </summary> 
    141         /// <returns>A mutable list, with an instance of each EntropySource.</returns> 
    142         public static Dictionary<Guid, EntropySource> Items 
    143         { 
    144             get 
    145             { 
    146                 lock (ManagerLibrary.Instance.EntropySourceManager.sources) 
    147                     return ManagerLibrary.Instance.EntropySourceManager.sources; 
    148             } 
    149         } 
    150  
    151         /// <summary> 
    152         /// Retrieves the instance of the EntropySource with the given GUID. 
    153         /// </summary> 
    154         /// <param name="value">The GUID of the EntropySource.</param> 
    155         /// <returns>The EntropySource instance.</returns> 
    156         public static EntropySource GetInstance(Guid value) 
    157         { 
    158             lock (ManagerLibrary.Instance.EntropySourceManager.sources) 
    159             { 
    160                 if (!ManagerLibrary.Instance.EntropySourceManager.sources.ContainsKey(value)) 
    161                     throw new EntropySourceNotFoundException(value); 
    162                 return ManagerLibrary.Instance.EntropySourceManager.sources[value]; 
    163             } 
    164         } 
    165  
    166         /// <summary> 
    167         /// Allows plugins to register EntropySources with the main program. Thread-safe. 
    168         /// </summary> 
    169         /// <param name="source">The source of entropy to add.</param> 
    170         public static void Register(EntropySource source) 
    171         { 
    172             EntropySourceManager manager = ManagerLibrary.Instance.EntropySourceManager; 
    173             lock (ManagerLibrary.Instance.EntropySourceManager.sources) 
    174                 manager.sources.Add(source.Guid, source); 
    175             manager.entropyThread.AddEntropySource(source); 
    176  
    177             OnEntropySourceRegistered(new EntropySourceRegistrationEventArgs(source.Guid)); 
    178         } 
    179  
    180         /// <summary> 
    181         /// Calls the EntropySourceRegistered event handlers. 
    182         /// </summary> 
    183         private static void OnEntropySourceRegistered(EntropySourceRegistrationEventArgs e) 
    184         { 
    185             if (EntropySourceRegistered != null) 
    186                 EntropySourceRegistered(ManagerLibrary.Instance.EntropySourceManager, e); 
     133        internal EntropySourceRegistrar() 
     134        { 
     135            Poller = new EntropyPoller(); 
     136            Poller.AddEntropySource(new KernelEntropySource()); 
    187137        } 
    188138 
     
    190140        /// Gets the entropy poller instance associated with this manager. 
    191141        /// </summary> 
    192         public EntropyPoller Poller 
    193         { 
    194             get 
    195             { 
    196                 return entropyThread; 
    197             } 
    198         } 
    199  
    200         /// <summary> 
    201         /// Global static instance of the EntropySourceRegisteredFunction, 
    202         /// called whenever the EntropySourceManager.Register is invoked. 
    203         /// </summary> 
    204         public static EventHandler<EntropySourceRegistrationEventArgs> 
    205             EntropySourceRegistered { get; set; } 
     142        public EntropyPoller Poller { get; private set; } 
    206143         
    207144        /// <summary> 
     
    209146        /// </summary> 
    210147        private Dictionary<Guid, EntropySource> sources = new Dictionary<Guid, EntropySource>(); 
    211  
    212         /// <summary> 
    213         /// The entropy thread gathering entropy for the RNGs. 
    214         /// </summary> 
    215         private EntropyPoller entropyThread = new EntropyPoller(); 
    216148    }; 
    217  
    218     public class EntropySourceRegistrationEventArgs : EventArgs 
    219     { 
    220         /// <summary> 
    221         /// Constructor. 
    222         /// </summary> 
    223         /// <param name="value">The GUID of the newly registered/unregistered entropy 
    224         /// source.</param> 
    225         public EntropySourceRegistrationEventArgs(Guid value) 
    226         { 
    227             Guid = value; 
    228         } 
    229  
    230         /// <summary> 
    231         /// The GUID of the newly registered/unregistered entropy source. 
    232         /// </summary> 
    233         public Guid Guid { get; private set; } 
    234     } 
    235149         
    236150    /// <summary> 
  • branches/eraser6/CodeReview/Eraser.Manager/Eraser.Manager.csproj

    r1777 r1792  
    7070    <Compile Include="Executor.cs" /> 
    7171    <Compile Include="FileSystem.cs" /> 
     72    <Compile Include="IRegistrar.cs" /> 
    7273    <Compile Include="Language.cs" /> 
    7374    <Compile Include="ManagerLibrary.cs" /> 
  • branches/eraser6/CodeReview/Eraser.Manager/ManagerLibrary.cs

    r1772 r1792  
    4242            SettingsManager = settings; 
    4343 
    44             EntropySourceManager = new EntropySourceManager(); 
     44            EntropySourceManager = new EntropySourceRegistrar(); 
    4545            PRNGManager = new PrngManager(); 
    46             ErasureMethodManager = new ErasureMethodManager(); 
     46            ErasureMethodManager = new ErasureMethodRegistrar(); 
    4747            FileSystemManager = new FileSystemManager(); 
    4848            Host = new Plugin.DefaultHost(); 
     
    8585        /// The global instance of the EntropySource Manager 
    8686        /// </summary> 
    87         internal EntropySourceManager EntropySourceManager; 
     87        public EntropySourceRegistrar EntropySourceManager { get; private set; } 
    8888 
    8989        /// <summary> 
    9090        /// The global instance of the PRNG Manager. 
    9191        /// </summary> 
    92         internal PrngManager PRNGManager; 
     92        public PrngManager PRNGManager { get; private set; } 
    9393 
    9494        /// <summary> 
    9595        /// The global instance of the Erasure method manager. 
    9696        /// </summary> 
    97         internal ErasureMethodManager ErasureMethodManager; 
     97        public ErasureMethodRegistrar ErasureMethodManager { get; private set; } 
    9898 
    9999        /// <summary> 
    100100        /// The global instance of the File System manager. 
    101101        /// </summary> 
    102         internal FileSystemManager FileSystemManager; 
     102        public FileSystemManager FileSystemManager { get; private set; } 
    103103 
    104104        /// <summary> 
  • branches/eraser6/CodeReview/Eraser.Manager/Method.cs

    r1767 r1792  
    3434    /// streams, not unused drive space. 
    3535    /// </summary> 
    36     public abstract class ErasureMethod 
     36    public abstract class ErasureMethod : IRegisterable 
    3737    { 
    3838        public override string ToString() 
     
    352352    /// do not have run-time equivalents; they all are compile-time. 
    353353    /// </summary> 
    354     public class ErasureMethodManager 
     354    public class ErasureMethodRegistrar : Registrar<ErasureMethod> 
    355355    { 
    356356        #region Default Erasure method 
     
    398398        public static readonly ErasureMethod Default = new DefaultMethod(); 
    399399        #endregion 
    400  
    401         #region Registrar fields 
    402         /// <summary> 
    403         /// Retrieves all currently registered erasure methods. 
    404         /// </summary> 
    405         /// <returns>A mutable list, with an instance of each method.</returns> 
    406         public static Dictionary<Guid, ErasureMethod> Items 
    407         { 
    408             get 
    409             { 
    410                 Dictionary<Guid, ErasureMethod> result = new Dictionary<Guid, ErasureMethod>(); 
    411  
    412                 lock (ManagerLibrary.Instance.ErasureMethodManager.methods) 
    413                 { 
    414                     //Iterate over every item registered. 
    415                     Dictionary<Guid, MethodConstructorInfo>.Enumerator iter = 
    416                         ManagerLibrary.Instance.ErasureMethodManager.methods.GetEnumerator(); 
    417                     while (iter.MoveNext()) 
    418                     { 
    419                         MethodConstructorInfo info = iter.Current.Value; 
    420                         result.Add(iter.Current.Key, 
    421                             (ErasureMethod)info.Constructor.Invoke(info.Parameters)); 
    422                     } 
    423                 } 
    424  
    425                 return result; 
    426             } 
    427         } 
    428  
    429         /// <summary> 
    430         /// Retrieves the instance of the erasure method with the given GUID. 
    431         /// </summary> 
    432         /// <param name="value">The GUID of the erasure method.</param> 
    433         /// <returns>The erasure method instance.</returns> 
    434         public static ErasureMethod GetInstance(Guid value) 
    435         { 
    436             lock (ManagerLibrary.Instance.ErasureMethodManager.methods) 
    437             { 
    438                 if (!ManagerLibrary.Instance.ErasureMethodManager.methods.ContainsKey(value)) 
    439                     throw new ErasureMethodNotFoundException(value); 
    440                 MethodConstructorInfo info = ManagerLibrary.Instance.ErasureMethodManager.methods[value]; 
    441                 return (ErasureMethod)info.Constructor.Invoke(info.Parameters); 
    442             } 
    443         } 
    444  
    445         /// <summary> 
    446         /// Allows plug-ins to register methods with the main program. Thread-safe. 
    447         /// </summary> 
    448         /// <param name="method">The method to register. Only the type is examined.</param> 
    449         public static void Register(ErasureMethod method) 
    450         { 
    451             Register(method, new object[0]); 
    452         } 
    453  
    454         /// <summary> 
    455         /// Allows plug-ins to register methods with the main program. Thread-safe. 
    456         /// </summary> 
    457         /// <param name="method">The method to register. Only the type is examined.</param> 
    458         /// <param name="parameters">The parameter list to be passed to the constructor.</param> 
    459         public static void Register(ErasureMethod method, object[] parameters) 
    460         { 
    461             //Get the constructor for the class. 
    462             ConstructorInfo ctor = null; 
    463             if (parameters == null || parameters.Length == 0) 
    464                 ctor = method.GetType().GetConstructor(Type.EmptyTypes); 
    465             else 
    466             { 
    467                 Type[] parameterTypes = new Type[parameters.Length]; 
    468                 for (int i = 0; i < parameters.Length; ++i) 
    469                     parameterTypes[i] = parameters[i].GetType(); 
    470                 ctor = method.GetType().GetConstructor(parameterTypes); 
    471             } 
    472  
    473             //Check for a valid constructor. 
    474             if (ctor == null) 
    475                 throw new ArgumentException("Registered erasure methods must contain " + 
    476                     "a parameterless constructor that is called whenever clients request " + 
    477                     "for an instance of the method. If a constructor requires parameters, " + 
    478                     "specify it in the parameters parameter."); 
    479  
    480             //Insert the entry 
    481             lock (ManagerLibrary.Instance.ErasureMethodManager.methods) 
    482             { 
    483                 MethodConstructorInfo info = new MethodConstructorInfo(); 
    484                 info.Constructor = ctor; 
    485                 info.Parameters = parameters == null || parameters.Length == 0 ? null : parameters; 
    486                 ManagerLibrary.Instance.ErasureMethodManager.methods.Add(method.Guid, info); 
    487             } 
    488  
    489             //Broadcast the event 
    490             OnMethodRegistered(new ErasureMethodRegistrationEventArgs(method.Guid)); 
    491         } 
    492  
    493         /// <summary> 
    494         /// Unregisters an erasure method from the registrar. 
    495         /// </summary> 
    496         /// <param name="value">The erasure method to unregister.</param> 
    497         public static void Unregister(Guid value) 
    498         { 
    499             if (!ManagerLibrary.Instance.ErasureMethodManager.methods.ContainsKey(value)) 
    500                 throw new ArgumentException("The GUID of the erasure method to remove " + 
    501                     "refers to an invalid erasure method."); 
    502  
    503             ManagerLibrary.Instance.ErasureMethodManager.methods.Remove(value); 
    504             OnMethodUnregistered(new ErasureMethodRegistrationEventArgs(value)); 
    505         } 
    506  
    507         /// <summary> 
    508         /// Holds information on how to construct a new instance of an erasure method. 
    509         /// </summary> 
    510         private struct MethodConstructorInfo 
    511         { 
    512             /// <summary> 
    513             /// The reference to the constructor method. 
    514             /// </summary> 
    515             public ConstructorInfo Constructor; 
    516  
    517             /// <summary> 
    518             /// The parameter list. 
    519             /// </summary> 
    520             public object[] Parameters; 
    521         } 
    522  
    523         /// <summary> 
    524         /// The list of currently registered erasure methods. 
    525         /// </summary> 
    526         private Dictionary<Guid, MethodConstructorInfo> methods = 
    527             new Dictionary<Guid, MethodConstructorInfo>(); 
    528  
    529         /// <summary> 
    530         /// Called whenever an erasure method is registered. 
    531         /// </summary> 
    532         public static EventHandler<ErasureMethodRegistrationEventArgs> 
    533             MethodRegistered { get; set; } 
    534          
    535         /// <summary> 
    536         /// Called whenever an erasure method is unregistered. 
    537         /// </summary> 
    538         public static EventHandler<ErasureMethodRegistrationEventArgs> 
    539             MethodUnregistered { get; set; } 
    540  
    541         /// <summary> 
    542         /// Executes the MethodRegistered event handlers. 
    543         /// </summary> 
    544         /// <param name="guid">The GUID of the newly registered erasure method.</param> 
    545         private static void OnMethodRegistered(ErasureMethodRegistrationEventArgs e) 
    546         { 
    547             if (MethodRegistered != null) 
    548                 MethodRegistered(ManagerLibrary.Instance.ErasureMethodManager, e); 
    549         } 
    550  
    551         /// <summary> 
    552         /// Performs the MethodUnregistered event handlers. 
    553         /// </summary> 
    554         /// <param name="guid">The GUID of the unregistered erasure method.</param> 
    555         private static void OnMethodUnregistered(ErasureMethodRegistrationEventArgs e) 
    556         { 
    557             if (MethodUnregistered != null) 
    558                 MethodUnregistered(ManagerLibrary.Instance.ErasureMethodManager, e); 
    559         } 
    560         #endregion 
    561400    } 
    562401 
  • branches/eraser6/CodeReview/Eraser.Manager/Task.cs

    r1777 r1792  
    314314            Guid methodGuid = (Guid)info.GetValue("Method", typeof(Guid)); 
    315315            if (methodGuid == Guid.Empty) 
    316                 method = ErasureMethodManager.Default; 
     316                method = ErasureMethodRegistrar.Default; 
    317317            else 
    318                 method = ErasureMethodManager.GetInstance(methodGuid); 
     318                method = ManagerLibrary.Instance.ErasureMethodManager[methodGuid]; 
    319319        } 
    320320 
     
    349349            { 
    350350                method = value; 
    351                 MethodDefined = method != ErasureMethodManager.Default; 
     351                MethodDefined = method != ErasureMethodRegistrar.Default; 
    352352            } 
    353353        } 
     
    424424            : base() 
    425425        { 
    426             Method = ErasureMethodManager.Default; 
     426            Method = ErasureMethodRegistrar.Default; 
    427427        } 
    428428 
     
    496496                if (base.MethodDefined) 
    497497                    return base.Method; 
    498                 return ErasureMethodManager.GetInstance( 
    499                     ManagerLibrary.Settings.DefaultFileErasureMethod); 
     498                return ManagerLibrary.Instance.ErasureMethodManager[ 
     499                    ManagerLibrary.Settings.DefaultFileErasureMethod]; 
    500500            } 
    501501            set 
     
    557557            : base() 
    558558        { 
    559             Method = ErasureMethodManager.Default; 
     559            Method = ErasureMethodRegistrar.Default; 
    560560        } 
    561561 
     
    566566                if (base.MethodDefined) 
    567567                    return base.Method; 
    568                 return ErasureMethodManager.GetInstance( 
    569                     ManagerLibrary.Settings.DefaultUnusedSpaceErasureMethod); 
     568                return ManagerLibrary.Instance.ErasureMethodManager[ 
     569                    ManagerLibrary.Settings.DefaultUnusedSpaceErasureMethod]; 
    570570            } 
    571571            set 
  • branches/eraser6/CodeReview/Eraser/Program.cs

    r1791 r1792  
    263263 
    264264            //Refresh the list of erasure methods 
    265             Dictionary<Guid, ErasureMethod> methods = ErasureMethodManager.Items; 
    266             foreach (ErasureMethod method in methods.Values) 
     265            foreach (ErasureMethod method in ManagerLibrary.Instance.ErasureMethodManager) 
    267266            { 
    268267                Console.WriteLine(methodFormat, (method is UnusedSpaceErasureMethod) ? 
     
    283282            Task task = new Task(); 
    284283            ErasureMethod method = arguments.ErasureMethod == Guid.Empty ? 
    285                 ErasureMethodManager.Default : 
    286                 ErasureMethodManager.GetInstance(arguments.ErasureMethod); 
     284                ErasureMethodRegistrar.Default : 
     285                ManagerLibrary.Instance.ErasureMethodManager[arguments.ErasureMethod]; 
    287286            switch (arguments.Schedule.ToUpperInvariant()) 
    288287            { 
  • branches/eraser6/CodeReview/Eraser/SettingsPanel.cs

    r1768 r1792  
    4646            //For new plugins, register the callback. 
    4747            Host.Instance.PluginLoaded += OnNewPluginLoaded; 
    48             ErasureMethodManager.MethodRegistered += OnMethodRegistered; 
    49             ErasureMethodManager.MethodUnregistered += OnMethodUnregistered; 
     48            ManagerLibrary.Instance.ErasureMethodManager.Registered += OnMethodRegistered; 
     49            ManagerLibrary.Instance.ErasureMethodManager.Unregistered += OnMethodUnregistered; 
    5050 
    5151            //Load the values 
     
    8585        } 
    8686 
    87         private void OnMethodRegistered(object sender, ErasureMethodRegistrationEventArgs e) 
    88         { 
    89             ErasureMethod method = ErasureMethodManager.GetInstance(e.Guid); 
     87        private void OnMethodRegistered(object sender, EventArgs e) 
     88        { 
     89            ErasureMethod method = (ErasureMethod)sender; 
    9090            eraseFilesMethod.Items.Add(method); 
    9191            if (method is UnusedSpaceErasureMethod) 
     
    9393        } 
    9494 
    95         private void OnMethodUnregistered(object sender, ErasureMethodRegistrationEventArgs e) 
    96         { 
     95        private void OnMethodUnregistered(object sender, EventArgs e) 
     96        { 
     97            ErasureMethod method = (ErasureMethod)sender; 
    9798            foreach (object obj in eraseFilesMethod.Items) 
    98                 if (((ErasureMethod)obj).Guid == e.Guid) 
     99                if (((ErasureMethod)obj).Guid == method.Guid) 
    99100                { 
    100101                    eraseFilesMethod.Items.Remove(obj); 
     
    103104 
    104105            foreach (object obj in eraseUnusedMethod.Items) 
    105                 if (((ErasureMethod)obj).Guid == e.Guid) 
     106                if (((ErasureMethod)obj).Guid == method.Guid) 
    106107                { 
    107108                    eraseUnusedMethod.Items.Remove(obj); 
     
    129130 
    130131            //Refresh the list of erasure methods 
    131             Dictionary<Guid, ErasureMethod> methods = ErasureMethodManager.Items; 
    132             foreach (ErasureMethod method in methods.Values) 
     132            foreach (ErasureMethod method in ManagerLibrary.Instance.ErasureMethodManager) 
    133133            { 
    134134                eraseFilesMethod.Items.Add(method); 
  • branches/eraser6/CodeReview/Eraser/TaskDataSelectionForm.cs

    r1768 r1792  
    8484 
    8585            //And the methods list 
    86             Dictionary<Guid, ErasureMethod> methods = ErasureMethodManager.Items; 
    87             this.method.Items.Add(ErasureMethodManager.Default); 
    88             foreach (ErasureMethod method in methods.Values) 
     86            this.method.Items.Add(ErasureMethodRegistrar.Default); 
     87            foreach (ErasureMethod method in ManagerLibrary.Instance.ErasureMethodManager) 
    8988                this.method.Items.Add(method); 
    9089            if (this.method.Items.Count != 0) 
     
    187186        { 
    188187            if (!(method.SelectedItem is UnusedSpaceErasureMethod) && 
    189                 method.SelectedItem != ErasureMethodManager.Default) 
     188                method.SelectedItem != ErasureMethodRegistrar.Default) 
    190189            { 
    191190                if (unused.Checked) 
Note: See TracChangeset for help on using the changeset viewer.