public void ImportLegacyModification(string friendlyModificationName, string importedDirectoryPath, string[] importedFilePaths, LeagueModificationCategory category, ModificationImportWindow importWindow)
        {
            string repositoryName = Util.ExtractFileNameTokens(friendlyModificationName).Select(token => token.ToLower()).Join("-");
             string finalRepositoryPath = Path.Combine(repositoriesDirectory, repositoryName);
             var temporaryDirectory = temporaryFileService.AllocateTemporaryDirectory(TimeSpan.FromHours(1));
             var workingDirectory = Path.Combine(temporaryDirectory, "working");
             var contentDirectory = Path.Combine(workingDirectory, "content");
             var temporaryNestPath = Path.Combine(temporaryDirectory, "working_nest");
             fileSystemProxy.PrepareDirectory(contentDirectory);
             fileSystemProxy.PrepareDirectory(temporaryNestPath);

             var temporaryNest = new LocalDargonNest(temporaryNestPath);
             var inMemoryEgg = new InMemoryEgg(repositoryName, "legacy", workingDirectory);
             temporaryNest.InstallEgg(inMemoryEgg);

             var temporaryEggPath = Path.Combine(temporaryNestPath, inMemoryEgg.Name);

             var temporaryModification = modificationLoader.FromPath(temporaryEggPath);
             var info = temporaryModification.GetComponent<InfoComponent>();
             info.Id = Guid.NewGuid();
             info.Name = friendlyModificationName;

             var leagueComponent = temporaryModification.GetComponent<LeagueMetadataComponent>();
             leagueComponent.Category = category;

             var viewModel = new ModificationViewModel();
             var controller = new ModificationController(null, viewModel);
             viewModel.SetController(controller);
             viewModel.SetModification(temporaryModification);

             Application.Current.Dispatcher.BeginInvoke(
            new Action(() => {
               modificationViewModels.Add(viewModel);

               importWindow.Close();

               var modificationPhaseManager = new ModificationPhaseManager();
               var modificationPhaseFactory = new ModificationPhaseFactory(pofSerializer, fileSystemProxy, temporaryFileService, exeggutorService, modificationPhaseManager, modificationLoader, viewModel, leagueBuildUtilities, temporaryModification);
               controller.SetModificationPhaseManager(modificationPhaseManager);
               modificationPhaseManager.Transition(modificationPhaseFactory.Importing(importedDirectoryPath, importedFilePaths, finalRepositoryPath));
               controller.Initialize();
            }), DispatcherPriority.Send
             );

             //         var modification = modificationLoader.FromPath(e.FullPath);

             //         fileSystemProxy.MoveDirectory(temporaryEggPath, finalRepositoryPath);

             return;

            //         foreach (var relativeFilePath in importedRelativeFilePaths) {
            //            var importedFile = Path.Combine(modificationRoot, relativeFilePath);
            //            var contentFile = Path.Combine(contentDirectory, relativeFilePath);
            //            fileSystemProxy.PrepareParentDirectory(contentFile);
            //            fileSystemProxy.CopyFile(importedFile, contentFile);
            //         }
            //
            //         var workingDirectoryInfo = fileSystemProxy.GetDirectoryInfo(workingDirectory);

            //
            //         var destinationNestLockPath = Path.Combine(repositoriesDirectory, "LOCK");
            //         using (fileSystemProxy.OpenFile(destinationNestLockPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) {
            //            var temporaryNest = Path.Combine(temporaryDirectory, "working_nest");
            //            fileSystemProxy.PrepareDirectory(temporaryNest);
            //            var inMemoryEgg = new InMemoryEgg(repositoryName, "legacy", workingDirectory);
            //            var modificationsNest = new LocalDargonNest(temporaryNest);
            //            modificationsNest.InstallEgg(inMemoryEgg);
            //
            //            var temporaryEggPath = Path.Combine(temporaryNest, inMemoryEgg.Name);
            //            fileSystemProxy.MoveDirectory(temporaryEggPath, finalRepositoryPath);
            //         }
            //
            //         fileSystemProxy.DeleteDirectory(temporaryDirectory, true);
        }
        private void HandleRepositoriesDirectoryModified(object sender, FileSystemEventArgs e)
        {
            switch (e.ChangeType) {
            case WatcherChangeTypes.Changed:
               break;
            case WatcherChangeTypes.Created:
               var fileInfo = fileSystemProxy.GetFileInfo(e.FullPath);
               if (fileInfo.Attributes.HasFlag(FileAttributes.Directory)) {
                  if (fileInfo.Name.StartsWith(".")) {
                     logger.Info($"Ignoring modification candidate {fileInfo.Name} as name has leading period.");
                  } else if (displayedModificationNames.Contains(fileInfo.Name)) {
                     logger.Info($"Ignoring modification candidate {fileInfo.Name} as view model already exists.");
                  } else {
                     var modification = modificationLoader.FromPath(e.FullPath);
                     var viewModel = new ModificationViewModel();
                     var controller = new ModificationController(modification, viewModel);
                     viewModel.SetController(controller);
                     viewModel.SetModification(modification);
                     var modificationPhaseManager = new ModificationPhaseManager();
                     var modificationPhaseFactory = new ModificationPhaseFactory(pofSerializer, fileSystemProxy, temporaryFileService, exeggutorService, modificationPhaseManager, modificationLoader, viewModel, leagueBuildUtilities, modification);
                     modificationPhaseManager.Transition(modificationPhaseFactory.Idle());
                     controller.SetModificationPhaseManager(modificationPhaseManager);
                     controller.Initialize();

                     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => {
                        modificationViewModels.Add(viewModel);
                     }));
                  }
               }
               break;
            case WatcherChangeTypes.Deleted:
               var removedViewModel = modificationViewModels.FirstOrDefault(x => x.RepositoryName.Equals(e.Name, StringComparison.OrdinalIgnoreCase));
               if (removedViewModel == null) {
                  logger.Error("Failed to find viewmodel match for removed directory " + e.FullPath);
               } else {
                  Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => {
                     modificationViewModels.Remove(removedViewModel);
                  }));
               }
               break;
            case WatcherChangeTypes.Renamed:
               var renamedArgs = (RenamedEventArgs)e;
               var parentDirectory = new FileInfo(renamedArgs.FullPath).Directory;
               HandleRepositoriesDirectoryModified(sender, new FileSystemEventArgs(WatcherChangeTypes.Deleted, parentDirectory.FullName, renamedArgs.OldName));
               HandleRepositoriesDirectoryModified(sender, new FileSystemEventArgs(WatcherChangeTypes.Created, parentDirectory.FullName, renamedArgs.Name));
               break;
             }
        }