/// <summary> Clears all of the data loaded into this configuration </summary> public void ClearAll() { RootPaths.Clear(); rootPathsDictionary.Clear(); Components.Clear(); RestrictionRanges.Clear(); Error = null; }
/// <summary> /// Get file path /// </summary> /// <param name="relativePath">Relative file path</param> /// <returns>Return the file full path</returns> public string GetFilePath(string relativePath) { if (string.IsNullOrWhiteSpace(relativePath)) { return(string.Empty); } if (RootPaths.IsNullOrEmpty()) { return(relativePath); } var rootPath = dataSelectionProvider.Get(PathSelectMode); string fullPath = Path.Combine(rootPath, relativePath); return(fullPath.Replace("\\", "/")); }
public void AddRoot(string ChildSegment, Engine_Path_Endpoint Child) { // Ensure the dictionary is built correctly ensure_dictionary_built(); // Does an endpoint already exist here? if (rootPathsDictionary.ContainsKey(ChildSegment)) { Engine_Path_Endpoint matchingEndpoint = rootPathsDictionary[ChildSegment]; RootPaths.Remove(matchingEndpoint); } rootPathsDictionary[ChildSegment] = Child; RootPaths.Add(Child); }
/// <summary> /// get file access path with random /// </summary> /// <param name="fileRelativePath">relative file path</param> /// <returns></returns> public string GetFilePath(string fileRelativePath) { if (string.IsNullOrWhiteSpace(fileRelativePath)) { return(string.Empty); } if (RootPaths.IsNullOrEmpty()) { return(fileRelativePath); } #region get root path string rootPath = string.Empty; int rootCount = RootPaths.Count; if (rootCount == 1) { rootPath = RootPaths[0]; } else { switch (PathPattern) { case FilePathPattern.Random: var random = new Random(); int ranIndex = random.Next(0, rootCount); rootPath = RootPaths[ranIndex]; break; } } #endregion string fullPath = Path.Combine(rootPath, fileRelativePath); fullPath = fullPath.Replace("\\", "/"); return(fullPath); }