Пример #1
0
 protected CustomErasureMethod(SerializationInfo info, StreamingContext context)
 {
     Name = info.GetString("Name");
        Guid = (Guid)info.GetValue("GUID", Guid.GetType());
        RandomizePasses = info.GetBoolean("RandomizePasses");
        List<PassData> passes = (List<PassData>)
     info.GetValue("Passes", typeof(List<PassData>));
        Passes = new ErasureMethodPass[passes.Count];
        for (int i = 0; i != passes.Count; ++i)
     Passes[i] = passes[i];
 }
 private ListViewItem AddPass(ErasureMethodPass pass)
 {
     ListViewItem item = new ListViewItem((passesLv.Items.Count + 1).ToString(
     CultureInfo.CurrentCulture));
        item.Tag = pass;
        if (pass.Function == ErasureMethod.WriteRandom)
     item.SubItems.Add(S._("Random Data"));
        else
     item.SubItems.Add(S._("Constant ({0} bytes)", ((byte[])pass.OpaqueValue).Length));
        passesLv.Items.Add(item);
        return item;
 }
Пример #3
0
 protected static ErasureMethodPass[] ShufflePasses(ErasureMethodPass[] passes)
 {
     ErasureMethodPass[] result = new ErasureMethodPass[passes.Length];
        passes.CopyTo(result, 0);
        Prng rand = PrngManager.GetInstance(ManagerLibrary.Settings.ActivePrng);
        for (int i = 0; i < result.Length; ++i)
        {
     int val = rand.Next(result.Length - 1);
     ErasureMethodPass tmpPass = result[val];
     result[val] = result[i];
     result[i] = tmpPass;
        }
        return result;
 }
 private void passesDuplicateBtn_Click(object sender, EventArgs e)
 {
     SavePass(currentPass);
        foreach (ListViewItem item in passesLv.SelectedItems)
        {
     ErasureMethodPass oldPass = (ErasureMethodPass)item.Tag;
     ErasureMethodPass pass = new ErasureMethodPass(
      oldPass.Function, oldPass.OpaqueValue);
     AddPass(pass);
        }
 }
 private void passesAddBtn_Click(object sender, EventArgs e)
 {
     if (currentPass != null)
     SavePass(currentPass);
        ErasureMethodPass pass = new ErasureMethodPass(ErasureMethod.WriteRandom, null);
        ListViewItem item = AddPass(pass);
        if (passesLv.SelectedIndices.Count > 0)
        {
     item.Remove();
     passesLv.Items.Insert(passesLv.SelectedIndices[passesLv.SelectedIndices.Count - 1] + 1,
      item);
     RenumberPasses();
        }
 }
Пример #6
0
 public PassData(ErasureMethodPass pass)
 {
     if (pass.Function == ErasureMethod.WriteConstant)
     {
      Random = false;
      OpaqueValue = pass.OpaqueValue;
     }
     else if (pass.Function == ErasureMethod.WriteRandom)
     {
      Random = true;
     }
     else
      throw new ArgumentException(S._("The custom erasure method can only comprise " +
       "passes containing constant or random passes"));
 }