/// <summary> /// Gets the file search operter instance /// </summary> /// <param name="source">The source.</param> /// <returns></returns> public fileTextOperater getOperater(lexiconSourceTypeEnum source) { lexiconSourceFile sourceFile = this.First(x => x.sourceType == source); fileTextOperater output = new fileTextOperater(sourceFile.filepath); return(output); }
/// <summary> /// Gets the file paths for selected source type. If <c>regexPattern</c> is specified, local path to the resource has to match the regex /// </summary> /// <param name="source">The source type to query.</param> /// <param name="regexPattern">The regex pattern to filter out available resources</param> /// <returns>List of paths</returns> public List <string> getFilePaths(lexiconSourceTypeEnum source, String regexPattern = "") { List <string> output = new List <string>(); foreach (lexiconSourceFile item in this) { if (source.HasFlag(item.sourceType)) { Boolean ok = false; if (regexPattern.isNullOrEmpty()) { ok = true; } else { ok = Regex.IsMatch(item.filepath, regexPattern); } if (ok) { output.Add(item.filepath); } } } return(output); }
//public DataTable getDataTable(lexiconSourceTypeEnum source) //{ // lexiconSourceFile sourceFile = this.First(x => x.sourceType == source); // dataTableExportEnum format = sourceFile.filepath.getExportFormatByExtension(); // DataTable output = sourceFile.deserialize //} public void Add(lexiconSourceTypeEnum type, string filepath) { lexiconSourceFile sfile = new lexiconSourceFile(); sfile.sourceType = type; sfile.filepath = filepath; Add(sfile); }
public List <string> getFilePaths(lexiconSourceTypeEnum source) { List <string> output = new List <string>(); foreach (lexiconSourceFile item in this) { if (source.HasFlag(item.sourceType)) { output.Add(item.filepath); } } return(output); }
protected void findAndAdd(lexiconSourceTypeEnum type, string pattern, ILogBuilder logger = null) { folderNode folder = appManager.Application.folder_resources; var found = folder.findFiles(pattern); if (found.Any()) { foreach (String f in found) { String relPath = f.removeStartsWith(folder.path).Trim(Path.PathSeparator); Add(type, relPath); logger.log("Resource found [" + type.ToString() + "] at: " + relPath); } } else { logger.log("Resource _not found_ for [" + type.ToString() + "]"); } }
/// <summary> /// Search the source /// </summary> /// <param name="needles">The needles.</param> /// <param name="sourceType">Type of the source.</param> /// <param name="useRegex">if set to <c>true</c> [use regex].</param> /// <returns></returns> public fileTextSearchMultiSourceSet sourceSearch(IEnumerable <string> needles, lexiconSourceTypeEnum sourceType, bool useRegex = false) { List <string> filepaths = settings.sourceFiles.getFilePaths(sourceType); fileTextOperaterMulti fileOperaters = new fileTextOperaterMulti(filepaths); fileTextSearchMultiSourceSet fileMultiSourceSet = new fileTextSearchMultiSourceSet(needles, filepaths, useRegex); foreach (var fop in fileOperaters) { fileMultiSourceSet[fop.Key] = fop.Value.Search(needles, useRegex); } return(fileMultiSourceSet); }
/// <summary> /// Gets the file paths for selected source type. If <c>regexPattern</c> is specified, local path to the resource has to match the regex /// </summary> /// <param name="source">The source type to query.</param> /// <param name="regexPattern">The regex pattern to filter out available resources</param> /// <returns>List of paths</returns> public string getFilePath(lexiconSourceTypeEnum source, String regexPattern = "") { return(getFilePaths(source, regexPattern).First()); }
public string getFilePath(lexiconSourceTypeEnum source) { return(getFilePaths(source).First()); }