private bool Do(Happened happened, bool isFolder, EventArgs args, ref string message) { switch (happened) { case Happened.Created: { return(isFolder ? BrowseSystem.CreateProject((ProjectArgs)args, Control, ref message) : BrowseSystem.CreateFile((FileArgs)args, Control, ref message)); } case Happened.Deleted: { return(isFolder ? TransactionDirectory.RemoveDirectory(Path.Combine(Control.FSWorker.WorkDirectory, ((ProjectArgs)args).Project)) : TransactionFile.DeleteFiles((FileArgs)args)); } } return(false); }
public static bool RenameProject(ProjectArgs args, IBasicPanel <Project> control, ref string message) { string path = Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.From); ComplexTransaction transaction = new ComplexTransaction(); transaction.AddOperation(() => TransactionDirectory.CopyDirectory(path, Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To)), () => { if (!TransactionDirectory.RemoveDirectory( Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To))) { Transaction.Current.Rollback(); } }); transaction.AddOperation(() => { TransactionDirectory.RemoveDirectory(path); }, new List <string> { path }); transaction.AddOperation(() => { TransactionFile.DeleteFiles( new FileArgs( new List <string> { Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To, args.RenamedArgs.From + ProjectExtension) }, args.RenamedArgs.From, Happened.Deleted, (b, s, arg) => { })); }, new List <string> { Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To, args.RenamedArgs.From + ProjectExtension) }); transaction.DoOperation(); return(Save(control.Save(args.RenamedArgs.To, control.SaveItemManager.DoSave(args)), Path.Combine(control.FSWorker.WorkDirectory, args.RenamedArgs.To, args.RenamedArgs.To + ProjectExtension), ref message)); }
public static bool RemoveFile(FileArgs args, IBasicPanel <Project> control, ref string message) { TransactionFile.DeleteFiles(args); return(Save(control.Save(args.Project, control.SaveItemManager.DoSave(args)), Path.Combine(control.FSWorker.WorkDirectory, args.Project, args.Project + ProjectExtension), ref message)); }