public void AddSearchFolder(ResolveFileMode mode, string folder) { if (!_additionalSearchFolders.ContainsKey(mode)) { _additionalSearchFolders[mode] = new List <string>(); } _additionalSearchFolders[mode].Add(folder); }
private string SearchExistingFile(string file, ResolveFileMode mode, params string[] folders) { foreach (string folder in folders) { if (folder == null) { continue; } string fn = Path.Combine(folder, file); if (System.IO.File.Exists(fn)) { return(fn); } } var additionalFoldersCtx = this; while (additionalFoldersCtx != null) { if (additionalFoldersCtx._additionalSearchFolders.ContainsKey(mode)) { foreach (string folder in additionalFoldersCtx._additionalSearchFolders[mode]) { string fn = Path.Combine(folder, file); if (System.IO.File.Exists(fn)) { return(fn); } } } additionalFoldersCtx = additionalFoldersCtx._parent; } if (System.IO.File.Exists(file)) { return(file); } var allFolders = new List <string>(folders); if (_additionalSearchFolders.ContainsKey(mode)) { allFolders.AddRange(_additionalSearchFolders[mode]); } throw new Exception(String.Format("DBSH-00063 Could not find file {0}, searched in folders {1}", file, allFolders.CreateDelimitedText(";"))); }
public string ResolveFile(string file, ResolveFileMode mode) { switch (mode) { case ResolveFileMode.DbShell: return(SearchExistingFile(file, mode, GetExecutingFolder())); case ResolveFileMode.Template: return(SearchExistingFile(file, mode, GetTemplatesFolder(), GetExecutingFolder())); case ResolveFileMode.Input: return(SearchExistingFile(file, mode, GetExecutingFolder())); case ResolveFileMode.Output: var outputFolder = GetDefaultOutputFolder(); if (outputFolder != null) { return(Path.Combine(outputFolder, file)); } return(file); } return(file); }
public void AddSearchFolder(ResolveFileMode mode, string folder) { if (!_additionalSearchFolders.ContainsKey(mode)) { _additionalSearchFolders[mode] = new List<string>(); } _additionalSearchFolders[mode].Add(folder); }
public string ResolveFile(string file, ResolveFileMode mode) { switch (mode) { case ResolveFileMode.DbShell: return SearchExistingFile(file, mode, GetExecutingFolder()); case ResolveFileMode.Template: return SearchExistingFile(file, mode, GetTemplatesFolder(), GetExecutingFolder()); case ResolveFileMode.Input: return SearchExistingFile(file, mode, GetExecutingFolder()); case ResolveFileMode.Output: var outputFolder = GetDefaultOutputFolder(); if (outputFolder != null) return Path.Combine(outputFolder, file); return file; } return file; }
private string SearchExistingFile(string file, ResolveFileMode mode, params string[] folders) { foreach (string folder in folders) { if (folder == null) continue; string fn = Path.Combine(folder, file); if (System.IO.File.Exists(fn)) return fn; } var additionalFoldersCtx = this; while (additionalFoldersCtx != null) { if (additionalFoldersCtx._additionalSearchFolders.ContainsKey(mode)) { foreach (string folder in additionalFoldersCtx._additionalSearchFolders[mode]) { string fn = Path.Combine(folder, file); if (System.IO.File.Exists(fn)) return fn; } } additionalFoldersCtx = additionalFoldersCtx._parent; } if (System.IO.File.Exists(file)) return file; var allFolders = new List<string>(folders); if (_additionalSearchFolders.ContainsKey(mode)) { allFolders.AddRange(_additionalSearchFolders[mode]); } throw new Exception(String.Format("DBSH-00063 Could not find file {0}, searched in folders {1}", file, allFolders.CreateDelimitedText(";"))); }