ResolveRelativePath() public static méthode

Resolve a relative path against the given root path.
public static ResolveRelativePath ( string relativePath, string resolutionRootFullPath ) : string
relativePath string Relative path to resolve
resolutionRootFullPath string Root full path for the resolution of
Résultat string
Exemple #1
0
        public bool TryGetProjectRuleSetFilePath(Project project, RuleSetDeclaration declaration, out string fullFilePath)
        {
            List <string> options = new List <string>();

            options.Add(declaration.RuleSetPath);                                                   // Might be a full path
            options.Add(PathHelper.ResolveRelativePath(declaration.RuleSetPath, project.FullName)); // Relative to project
            // Note: currently we don't search in rule set directories since we expect the project rule set
            // to be relative to the project. We can add this in the future if it will be needed.

            fullFilePath = options.FirstOrDefault(fileSystem.File.Exists);

            return(!string.IsNullOrWhiteSpace(fullFilePath));
        }
        /// <summary>
        /// Find all the <see cref="RuleSetInclude"/>, for a <paramref name="ruleSet"/>,
        /// which are referencing rule sets under <paramref name="rootDirectory"/>
        /// </summary>
        public static IEnumerable <RuleSetInclude> FindAllIncludesUnderRoot(RuleSet ruleSet, string rootDirectory)
        {
            Debug.Assert(ruleSet != null);
            Debug.Assert(!string.IsNullOrWhiteSpace(rootDirectory));


            string ruleSetRoot = PathHelper.ForceDirectoryEnding(Path.GetDirectoryName(ruleSet.FilePath));

            return(ruleSet.RuleSetIncludes.Where(include =>
            {
                string fullIncludePath = PathHelper.ResolveRelativePath(include.FilePath, ruleSetRoot);
                return PathHelper.IsPathRootedUnderRoot(fullIncludePath, rootDirectory);
            }));
        }