Changeset 2233 for trunk/eraser/Eraser/Program.cs
- Timestamp:
- 8/4/2010 9:44:20 AM (22 months ago)
- File:
-
- 1 edited
-
trunk/eraser/Eraser/Program.cs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser/Program.cs
r2232 r2233 93 93 /// The erasure method which the user specified on the command line. 94 94 /// </summary> 95 [Arg("method", "The erasure method to use", typeof( Guid), false, null, null)]96 public GuidErasureMethod { get; set; }95 [Arg("method", "The erasure method to use", typeof(string), false, null, null)] 96 public string ErasureMethod { get; set; } 97 97 98 98 /// <summary> … … 322 322 323 323 parameters for addtask: 324 eraser addtask [/method= <methodGUID>] [/schedule=(now|manually|restart)] <target> [target [...]]324 eraser addtask [/method=(<methodGUID>|<methodName>)] [/schedule=(now|manually|restart)] <target> [target [...]] 325 325 326 326 /method The Erasure method to use. … … 332 332 is next restarted. 333 333 334 where target is :334 where target is one of more of: 335 335 {0} 336 336 … … 341 341 342 342 parameters for importtasklist: 343 eraser importtasklist (file)[...]344 345 [file]A list of one or more files to import.343 eraser importtasklist <file>[...] 344 345 file A list of one or more files to import. 346 346 347 347 All arguments are case sensitive. … … 398 398 AddTaskArguments arguments = (AddTaskArguments)arg; 399 399 400 //Create the task then set the method as well as schedule400 //Create the task 401 401 Task task = new Task(); 402 ErasureMethod method = arguments.ErasureMethod == Guid.Empty ? 402 403 //Get the erasure method the user wants to use 404 ErasureMethod method = string.IsNullOrEmpty(arguments.ErasureMethod) ? 403 405 ErasureMethodRegistrar.Default : 404 ManagerLibrary.Instance.ErasureMethodRegistrar[arguments.ErasureMethod]; 406 ErasureMethodFromNameOrGuid(arguments.ErasureMethod); 407 408 //Define the schedule 405 409 switch (arguments.Schedule.ToUpperInvariant()) 406 410 { … … 442 446 { 443 447 //Yes, it is an ambiguity. Throw an error. 444 throw new InvalidOperationException("Ambiguous argument: {0} can be " +445 "handled by more than one erasure target." );448 throw new ArgumentException(S._("Ambiguous argument: {0} can be " + 449 "handled by more than one erasure target.", argument)); 446 450 } 447 451 } … … 467 471 using (eraserClient = CommandConnect()) 468 472 eraserClient.Tasks.Add(task); 473 } 474 475 private static ErasureMethod ErasureMethodFromNameOrGuid(string param) 476 { 477 try 478 { 479 return ManagerLibrary.Instance.ErasureMethodRegistrar[new Guid(param)]; 480 } 481 catch (FormatException) 482 { 483 //Invalid GUID. Check every registered erasure method for the name 484 string upperParam = param.ToUpperInvariant(); 485 ErasureMethod result = null; 486 foreach (ErasureMethod method in ManagerLibrary.Instance.ErasureMethodRegistrar) 487 { 488 if (method.Name.ToUpperInvariant() == upperParam) 489 if (result == null) 490 result = method; 491 else 492 throw new ArgumentException(S._("Ambiguous erasure method name: {0} " + 493 "identifies more than one erasure method.", param)); 494 } 495 } 496 497 throw new ArgumentException(S._("The provided Erasure Method '{0}' does not exist.", 498 param)); 469 499 } 470 500
Note: See TracChangeset
for help on using the changeset viewer.
