Example #1
0
 /// <summary> Clears all of the data loaded into this configuration </summary>
 public void ClearAll()
 {
     RootPaths.Clear();
     rootPathsDictionary.Clear();
     Components.Clear();
     RestrictionRanges.Clear();
     Error = null;
 }
Example #2
0
        /// <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("\\", "/"));
        }
Example #3
0
        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);
        }
Example #4
0
        /// <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);
        }