private MirrorAction GetDirectoryActionFromClient(FileOrDirectory directory, MirrorSituation situation, MirrorAction action) { var args = new MirrorEventArgs(directory.Path, situation, action); EventHandler <MirrorEventArgs> handler = StartingDirectory; if (handler != null) { handler(this, args); } if (args.PendingAction == MirrorAction.Skip || args.PendingAction == MirrorAction.Delete) { _skippedOrRemovedDirectories.Add(directory.Path); } return(args.PendingAction); }
private bool ShouldCreateDirectory(FileOrDirectory sourceDirectory) { var dest = GetDestination(sourceDirectory.Path); var situation = MirrorSituation.DirectoryExists; var defaultAction = MirrorAction.DoNothing; if (!SafeIO.Directory.Exists(dest)) { situation = MirrorSituation.DirectoryMissing; defaultAction = MirrorAction.Create; } var action = GetDirectoryActionFromClient(sourceDirectory, situation, defaultAction); Guard.Against(situation == MirrorSituation.DirectoryExists && action == MirrorAction.Create, "Told to create an existing directory"); Guard.Against(situation == MirrorSituation.DirectoryMissing && action == MirrorAction.Delete, "Told to remove an non-existant directory"); return(action == MirrorAction.Create); }