public void CanNotDelete_NonRecursively_NonEmptyDir() { if (Environment.OSVersion.Version.Major < 6) { Assert.Ignore("TxF not supported"); return; } // 1. create dir and file string dir = dllPath.CombineAssert("testing"); string file = dir.Combine("file"); File.WriteAllText(file, "hello"); // 2. test it using (var t = new FileTransaction("Can not delete non-empty directory")) { IDirectoryAdapter da = t; t.Begin(); Assert.That(da.Delete(dir, false), Is.False, "Did not delete non-empty dir."); IFileAdapter fa = t; fa.Delete(file); Assert.That(da.Delete(dir, false), "After deleting the file in the folder, the folder is also deleted."); t.Commit(); } }
public ExtractArtifactsDeploymentStep( ProjectInfo projectInfo, EnvironmentInfo environmentInfo, DeploymentInfo deploymentInfo, string artifactsFilePath, string targetArtifactsDirPath, IFileAdapter fileAdapter, IDirectoryAdapter directoryAdapter, IZipFileAdapter zipFileAdapter) { Guard.NotNull(projectInfo, "projectInfo"); Guard.NotNull(environmentInfo, "environmentInfo"); Guard.NotNull(deploymentInfo, "deploymentInfo"); Guard.NotNullNorEmpty(artifactsFilePath, "artifactsFilePath"); Guard.NotNullNorEmpty(targetArtifactsDirPath, "targetArtifactsDirPath"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(directoryAdapter, "directoryAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); _projectInfo = projectInfo; _environmentInfo = environmentInfo; _deploymentInfo = deploymentInfo; _artifactsFilePath = artifactsFilePath; _targetArtifactsDirPath = targetArtifactsDirPath; _fileAdapter = fileAdapter; _directoryAdapter = directoryAdapter; _zipFileAdapter = zipFileAdapter; }
private async Task <Result <File> > GetFileOrError(IFileAdapter fileAdapter) { var maybeFile = await _fileRepository.FindByName(fileAdapter.Name); if (maybeFile.HasValue) { return(Result.Fail <File>("Name is already taken")); } var idOrError = Identifier.Of(fileAdapter.Id); var nameOrError = Name.Of(fileAdapter.Name); var pathOrError = Path.Of(fileAdapter.Path); var extensionOrError = Extension.Of(fileAdapter.Extension); var result = Result.Combine(nameOrError, pathOrError, extensionOrError); if (result.Failure) { return(Result.Fail <File>(result.Message)); } var file = new File(idOrError.Value, nameOrError.Value, pathOrError.Value, extensionOrError.Value); return(Result.Ok(file)); }
public DeployWebAppDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IMsDeploy msDeploy, IArtifactsRepository artifactsRepository, IIisManager iisManager, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter, IApplicationConfiguration applicationConfiguration, IDirectoryAdapter directoryAdapter) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(msDeploy, "msDeploy"); Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNull(iisManager, "iisManager"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); Guard.NotNull(directoryAdapter, "directoryAdapter"); _msDeploy = msDeploy; _artifactsRepository = artifactsRepository; _iisManager = iisManager; _fileAdapter = fileAdapter; _zipFileAdapter = zipFileAdapter; _applicationConfiguration = applicationConfiguration; _directoryAdapter = directoryAdapter; }
public DeploySchedulerAppDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, ITaskScheduler taskScheduler, IPasswordCollector passwordCollector, IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNull(taskScheduler, "taskScheduler"); Guard.NotNull(passwordCollector, "passwordCollector"); Guard.NotNull(directoryAdapter, "directoryAdapter"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); _artifactsRepository = artifactsRepository; _taskScheduler = taskScheduler; _passwordCollector = passwordCollector; _directoryAdapter = directoryAdapter; _fileAdapter = fileAdapter; _zipFileAdapter = zipFileAdapter; }
public DeployNtServiceDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, INtServiceManager ntServiceManager, IPasswordCollector passwordCollector, IFailoverClusterManager failoverClusterManager, IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNull(ntServiceManager, "ntServiceManager"); Guard.NotNull(passwordCollector, "passwordCollector"); Guard.NotNull(failoverClusterManager, "failoverClusterManager"); Guard.NotNull(directoryAdapter, "directoryAdapter"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); _artifactsRepository = artifactsRepository; _ntServiceManager = ntServiceManager; _passwordCollector = passwordCollector; _failoverClusterManager = failoverClusterManager; _directoryAdapter = directoryAdapter; _fileAdapter = fileAdapter; _zipFileAdapter = zipFileAdapter; }
public DeployUberDeployerAgentDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, INtServiceManager ntServiceManager, IPasswordCollector passwordCollector, IFailoverClusterManager failoverClusterManager, IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter) : base( projectInfoRepository, environmentInfoRepository, artifactsRepository, ntServiceManager, passwordCollector, failoverClusterManager, directoryAdapter, fileAdapter, zipFileAdapter) { Guard.NotNull(directoryAdapter, "directoryAdapter"); _directoryAdapter = directoryAdapter; }
public CsvFileService(IFileAdapter <Haspel> fileAdapter) { myHaspelFileAdapter = fileAdapter; UpdateLocalData(); HaspelsChanged += async(s, e) => await myHaspelFileAdapter.WriteData(myHaspels.ToArray()).ContinueWith(_ => UpdateLocalData()); }
public Integration(IStarterPortal starter, IViewerPortal viewer, IFileAdapter file, ILogik logik) { _starter = starter; _viewer = viewer; _file = file; _logik = logik; _viewer.Nächste_Seite += Next; }
public CleanDirectoryDeploymentStep(IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, Lazy<string> dstDirPath, string[] excludedDirs) { Guard.NotNull(dstDirPath, "dstDirPath"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(directoryAdapter, "directoryAdapter"); _dstDirPath = dstDirPath; _directoryAdapter = directoryAdapter; _excludedDirs = excludedDirs; _fileAdapter = fileAdapter; }
public CleanDirectoryDeploymentStep(IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, Lazy <string> dstDirPath, string[] excludedDirs) { Guard.NotNull(dstDirPath, "dstDirPath"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(directoryAdapter, "directoryAdapter"); _dstDirPath = dstDirPath; _directoryAdapter = directoryAdapter; _excludedDirs = excludedDirs; _fileAdapter = fileAdapter; }
public TeamService(IFileAdapter <string> fileAdapter) { myTeamAdpater = fileAdapter; myTeams = myTeamAdpater.GetData().ToList(); isUpToDate = true; TeamsChanged += async(s, e) => { await myTeamAdpater.WriteData(myTeams.ToArray()); isUpToDate = false; }; }
public FileGenerator( IFileAdapter fileAdapter, IFileWriter fileWriter, ILineGenerator lineGenerator, IProgress <int?> progress ) { _fileAdapter = fileAdapter; _fileWriter = fileWriter; _lineGenerator = lineGenerator; _progress = progress; }
public CopyFilesDeploymentStep(IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, Lazy<string> srcDirPathProvider, Lazy<string> dstDirPath) { Guard.NotNull(directoryAdapter, "directoryAdapter"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(srcDirPathProvider, "srcDirPathProvider"); Guard.NotNull(dstDirPath, "srcDirPathProvider"); _directoryAdapter = directoryAdapter; _fileAdapter = fileAdapter; _srcDirPathProvider = srcDirPathProvider; _dstDirPath = dstDirPath; }
/// <summary> /// Creates a new instance of <see cref="AboutViewModel"/>. /// </summary> /// <param name="windowManager"></param> /// <param name="fileAdapter"></param> /// <param name="assemblyAdapter"></param> public AboutViewModel(IWindowManager windowManager, IHelperFactory helperFactory) { if (windowManager == null) { throw new ArgumentNullException("windowManager"); } if (helperFactory == null) { throw new ArgumentNullException("helperFactory"); } m_windowManager = windowManager; m_assemblyAdapter = helperFactory.BuildAssemblyAdapter(); m_fileAdapter = helperFactory.BuildFileAdapter(); }
public FileSorter( ILineParser <T> lineParser, ISortStrategy <GroupedItem <T> > sortStrategy, IComparer <GroupedItem <T> > comparer, IFileAdapter fileAdapter, IFileReader filereader, IFileWriter fileWriter, IProgress <SortProgress> progress = null ) { _lineParser = lineParser; _sortStrategy = sortStrategy; _comparer = comparer; _fileAdapter = fileAdapter; _fileReader = filereader; _fileWriter = fileWriter; _progress = progress; }
public async Task <Result> Execute(IFileAdapter fileAdapter) { var getFileOrError = await GetFileOrError(fileAdapter); if (getFileOrError.Failure) { return(Result.Fail(getFileOrError.Message)); } var saveFileOrError = await SaveFileOrError(getFileOrError.Value); if (saveFileOrError.Failure) { return(Result.Fail(saveFileOrError.Message)); } return(Result.Ok()); }
public DeployPowerShellScriptDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, IFileAdapter fileAdapter, IDirectoryAdapter directoryAdapter, IZipFileAdapter zipFileAdapter) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(directoryAdapter, "directoryAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); _artifactsRepository = artifactsRepository; _fileAdapter = fileAdapter; _directoryAdapter = directoryAdapter; _zipFileAdapter = zipFileAdapter; }
/// <summary> /// Creates a new instance of <see cref="ReggieBasicViewModel"/>. /// </summary> /// <param name="windowManager"></param> public ReggieBasicViewModel(IWindowManager windowManager, IHelperFactory helperFactory) { if (windowManager == null) { throw new ArgumentNullException("windowManager"); } if (helperFactory == null) { throw new ArgumentNullException("helperFactory"); } m_windowManager = windowManager; m_helperFactory = helperFactory; m_fileAdapter = helperFactory.BuildFileAdapter(); m_assemblyAdapter = helperFactory.BuildAssemblyAdapter(); m_persistence = helperFactory.BuildPersistenceService(); base.DisplayName = m_displayName; }
public async Task <Result> Save(IFileAdapter fileAdapter) { try { var sql = @" INSERT INTO [dbo].[Files] ([Id], [Name], [Path], [Extension]) VALUES (@Id, @Name, @Path, @Extension) "; await _uow.Connection.ExecuteAsync(sql, fileAdapter, transaction : _uow.Transaction); return(Result.Ok()); } catch (Exception ex) { _logger.LogError(ex.Message, ex); return(Result.Fail("Oops... something has gone wrong")); } }
private IFileAdapter SelectFileAdapter(string filename, bool batchMode = false) { IFileAdapter result = null; // first look for adapters whose extension matches that of our filename List <IFileAdapter> matchingAdapters = _fileAdapters.Where(adapter => adapter.Extension.Split(';').Any(s => filename.ToLower().EndsWith(s.Substring(1).ToLower()))).ToList(); result = matchingAdapters.FirstOrDefault(adapter => adapter.Identify(filename)); // if none of them match, then try all other adapters if (result == null) { result = _fileAdapters.Except(matchingAdapters).FirstOrDefault(adapter => adapter.Identify(filename)); } if (result == null && !batchMode) { MessageBox.Show("None of the installed plugins are able to open the file.", "Unsupported Format", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(result); }
public CreateManualDeploymentPackageDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter, string packageDirPath) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNullNorEmpty(packageDirPath, "packageDirPath"); Guard.NotNull(directoryAdapter, "directoryAdapter"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); _artifactsRepository = artifactsRepository; _directoryAdapter = directoryAdapter; _fileAdapter = fileAdapter; _zipFileAdapter = zipFileAdapter; PackageDirPath = packageDirPath; }
public DeployDbProjectDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, IDbScriptRunnerFactory dbScriptRunnerFactory, IDbVersionProvider dbVersionProvider, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNull(dbVersionProvider, "dbVersionProvider"); Guard.NotNull(dbScriptRunnerFactory, "dbScriptRunnerFactory"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); _artifactsRepository = artifactsRepository; _dbScriptRunnerFactory = dbScriptRunnerFactory; _dbVersionProvider = dbVersionProvider; _fileAdapter = fileAdapter; _zipFileAdapter = zipFileAdapter; }
public DeployDbProjectDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, IDbScriptRunnerFactory dbScriptRunnerFactory, IDbVersionProvider dbVersionProvider, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter, IScriptsToRunSelector createScriptsToRunSelector, IMsSqlDatabasePublisher databasePublisher, IDbManagerFactory dbManagerFactory, IUserNameNormalizer userNameNormalizer, IDirectoryAdapter directoryAdapter) : base(projectInfoRepository, environmentInfoRepository) { Guard.NotNull(artifactsRepository, "artifactsRepository"); Guard.NotNull(dbVersionProvider, "dbVersionProvider"); Guard.NotNull(dbScriptRunnerFactory, "dbScriptRunnerFactory"); Guard.NotNull(fileAdapter, "fileAdapter"); Guard.NotNull(zipFileAdapter, "zipFileAdapter"); Guard.NotNull(createScriptsToRunSelector, "createScriptsToRunWebSelector"); Guard.NotNull(databasePublisher, "databasePublisher"); Guard.NotNull(dbManagerFactory, "dbManagerFactory"); Guard.NotNull(userNameNormalizer, "userNameNormalizer"); Guard.NotNull(directoryAdapter, "directoryAdapter"); _artifactsRepository = artifactsRepository; _dbScriptRunnerFactory = dbScriptRunnerFactory; _dbVersionProvider = dbVersionProvider; _fileAdapter = fileAdapter; _zipFileAdapter = zipFileAdapter; _createScriptsToRunSelector = createScriptsToRunSelector; _databasePublisher = databasePublisher; _dbManagerFactory = dbManagerFactory; _userNameNormalizer = userNameNormalizer; _directoryAdapter = directoryAdapter; }
public DeployUberDeployerAgentDeploymentTask( IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IArtifactsRepository artifactsRepository, INtServiceManager ntServiceManager, IPasswordCollector passwordCollector, IFailoverClusterManager failoverClusterManager, IDirectoryAdapter directoryAdapter, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter) : base(projectInfoRepository, environmentInfoRepository, artifactsRepository, ntServiceManager, passwordCollector, failoverClusterManager, directoryAdapter, fileAdapter, zipFileAdapter) { Guard.NotNull(directoryAdapter, "directoryAdapter"); _directoryAdapter = directoryAdapter; }
///<summary> /// Reads all text in a file and returns the string of it. ///</summary> ///<param name="adapter"></param> ///<param name="path"></param> ///<param name="encoding"></param> ///<returns></returns> public static string ReadAllText(this IFileAdapter adapter, string path, Encoding encoding) { return(""); }
public DeployWebServiceDeploymentTask(IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IMsDeploy msDeploy, IArtifactsRepository artifactsRepository, IIisManager iisManager, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter) : base(projectInfoRepository, environmentInfoRepository, msDeploy, artifactsRepository, iisManager, fileAdapter, zipFileAdapter) { }
private void OpenFile(string filename = "") { OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = Settings.Default.LastDirectory; // Supported Types ofd.Filter = Tools.LoadFileFilters(_fileAdapters); DialogResult dr = DialogResult.OK; if (filename == string.Empty) { dr = ofd.ShowDialog(); } if (dr == DialogResult.OK) { if (filename == string.Empty) { filename = ofd.FileName; } IFileAdapter _tempAdapter = SelectFileAdapter(filename); try { if (_tempAdapter != null && _tempAdapter.Load(filename) == LoadResult.Success) { _fileAdapter = _tempAdapter; _fileOpen = true; _hasChanges = false; // Select Game Handler foreach (ToolStripItem tsi in tsbGameSelect.DropDownItems) { if (tsi.Text == Settings.Default.SelectedGameHandler) { _gameHandler = (IGameHandler)tsi.Tag; tsbGameSelect.Text = tsi.Text; tsbGameSelect.Image = tsi.Image; break; } } if (_gameHandler == null) { _gameHandler = (IGameHandler)tsbGameSelect.DropDownItems[0].Tag; } LoadEntries(); UpdateTextView(); UpdatePreview(); UpdateForm(); } Settings.Default.LastDirectory = new FileInfo(filename).DirectoryName; Settings.Default.Save(); } catch (Exception ex) { if (_tempAdapter != null) { MessageBox.Show(this, ex.ToString(), _tempAdapter.Name + " - " + _tempAdapter.Description + " Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(this, ex.ToString(), "Supported Format Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
public AdultsController(IFileAdapter fileAdapter) { FileAdapter = fileAdapter; }
public DeployWebServiceDeploymentTask(IProjectInfoRepository projectInfoRepository, IEnvironmentInfoRepository environmentInfoRepository, IMsDeploy msDeploy, IArtifactsRepository artifactsRepository, IIisManager iisManager, IFileAdapter fileAdapter, IZipFileAdapter zipFileAdapter, IApplicationConfiguration applicationConfiguration, IDirectoryAdapter directoryAdapter) : base(projectInfoRepository, environmentInfoRepository, msDeploy, artifactsRepository, iisManager, fileAdapter, zipFileAdapter, applicationConfiguration, directoryAdapter) { }
public AClass(IDirectoryAdapter da, IFileAdapter fa) { _Da = da; _Fa = fa; }
private void tsbBatchExportKUP_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Select the source directory containing text files..."; fbd.SelectedPath = Settings.Default.LastBatchDirectory == string.Empty ? Settings.Default.LastDirectory : Settings.Default.LastBatchDirectory; fbd.ShowNewFolderButton = false; if (fbd.ShowDialog() == DialogResult.OK) { string path = fbd.SelectedPath; int fileCount = 0; if (Directory.Exists(path)) { string[] types = _fileAdapters.Select(x => x.Extension.ToLower()).ToArray(); List <string> files = new List <string>(); foreach (string type in types) { if (type != "*.kup") { string[] subTypes = type.Split(';'); foreach (string subType in subTypes) { files.AddRange(Directory.GetFiles(path, subType, SearchOption.AllDirectories)); } } } // TODO: Ask how to handle overwrites and backups foreach (string file in files) { if (File.Exists(file)) { FileInfo fi = new FileInfo(file); IFileAdapter currentAdapter = SelectFileAdapter(file, true); if (currentAdapter != null) { KUP kup = new KUP(); currentAdapter.Load(file, true); foreach (IEntry entry in currentAdapter.Entries) { Entry kEntry = new Entry(); kEntry.Name = entry.Name; kEntry.EditedText = entry.EditedText; kEntry.OriginalText = entry.OriginalText; kEntry.MaxLength = entry.MaxLength; kup.Entries.Add(kEntry); if (currentAdapter.EntriesHaveSubEntries) { foreach (IEntry sub in entry.SubEntries) { Entry kSub = new Entry(); kSub.Name = sub.Name; kSub.EditedText = sub.EditedText; kSub.OriginalText = sub.OriginalText; kSub.MaxLength = sub.MaxLength; kSub.ParentEntry = entry; entry.SubEntries.Add(kSub); } } } kup.Save(fi.FullName + ".kup"); fileCount++; } } } MessageBox.Show("Batch export completed successfully. " + fileCount + " file(s) succesfully exported.", "Batch Export", MessageBoxButtons.OK, MessageBoxIcon.Information); } } Settings.Default.LastBatchDirectory = fbd.SelectedPath; Settings.Default.Save(); }
/// <summary> /// Reads all text from a file as part of a transaction /// </summary> /// <param name="adapter"></param> /// <param name="source"></param> /// <returns></returns> public static string ReadAllText(this IFileAdapter adapter, string source) { return(""); }
private void tsbBatchImportKUP_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Select the source directory containing text and kup file pairs..."; fbd.SelectedPath = Settings.Default.LastBatchDirectory == string.Empty ? Settings.Default.LastDirectory : Settings.Default.LastBatchDirectory; fbd.ShowNewFolderButton = false; if (fbd.ShowDialog() == DialogResult.OK) { string path = fbd.SelectedPath; int fileCount = 0; int importCount = 0; if (Directory.Exists(path)) { string[] types = _fileAdapters.Select(x => x.Extension.ToLower()).ToArray(); List <string> files = new List <string>(); foreach (string type in types) { if (type != "*.kup") { string[] subTypes = type.Split(';'); foreach (string subType in subTypes) { files.AddRange(Directory.GetFiles(path, subType, SearchOption.AllDirectories)); } } } foreach (string file in files) { if (File.Exists(file)) { FileInfo fi = new FileInfo(file); IFileAdapter currentAdapter = SelectFileAdapter(file, true); if (currentAdapter != null && currentAdapter.CanSave && File.Exists(fi.FullName + ".kup")) { KUP kup = KUP.Load(fi.FullName + ".kup"); currentAdapter.Load(file, true); foreach (IEntry entry in currentAdapter.Entries) { Entry kEntry = kup.Entries.Find(o => o.Name == entry.Name); if (kEntry != null) { entry.EditedText = kEntry.EditedText; } if (currentAdapter.EntriesHaveSubEntries && kEntry != null) { foreach (IEntry sub in entry.SubEntries) { Entry kSub = (Entry)kEntry.SubEntries.Find(o => o.Name == sub.Name); if (kSub != null) { sub.EditedText = kSub.EditedText; } } } } currentAdapter.Save(); importCount++; } fileCount++; } } MessageBox.Show("Batch import completed successfully. " + importCount + " of " + fileCount + " files succesfully imported.", "Batch Import", MessageBoxButtons.OK, MessageBoxIcon.Information); } } Settings.Default.LastBatchDirectory = fbd.SelectedPath; Settings.Default.Save(); }
/// <summary> /// Read all lines in the given path. /// </summary> /// <param name="adapter"></param> /// <param name="filePath"></param> public static IEnumerable <string> ReadAllLines(this IFileAdapter adapter, string filePath) { return(new[] { "" }); }
public static void WriteAllLines(this IFileAdapter a, string path, IEnumerable <string> lines) { }
public CsvRepostory(IFileAdapter fileAdapter) { _fileAdapter = fileAdapter; }