private string ParseSpecificPath(string unresolvedPath, string specificValue,
                                         PathResolutionOptions options)
        {
            string wrappedSpecificValue = _specificProcessor.WrapSpecificValue(specificValue);

            bool containsSpecific = unresolvedPath.Contains(
                wrappedSpecificValue, StringComparison.InvariantCulture
                );

            if (containsSpecific)
            {
                if (options.ReturnRelativePath)
                {
                    string resolvedPath = unresolvedPath.Replace(
                        wrappedSpecificValue, string.Empty
                        );

                    return(PathHelper.TrimStartDirectorySeparatorChar(resolvedPath));
                }

                string resolvedSpecificValue = _specificProcessor.ResolveSpecificValue(
                    specificValue
                    );

                return(unresolvedPath.Replace(wrappedSpecificValue, resolvedSpecificValue));
            }

            string message =
                "Failed to parse log folder path: invalid specific path value. " +
                $"Argument: {unresolvedPath}";

            throw new ArgumentException(message, nameof(unresolvedPath));
        }
Ejemplo n.º 2
0
        public static string ResolveRelativePath(string unresolvedPath)
        {
            var options = new PathResolutionOptions
            {
                UnifyDirectorySeparatorChars = true,
                UsePlatformIndependentDirectorySeparatorChar = true,
                ReturnRelativePath = true
            };

            return(ResolvePath(unresolvedPath, options));
        }