Example #1
0
        /// <summary>
        /// Factory method to create a new <see cref="PurePath"/> instance
        /// based upon the current operating system.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="options"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool TryCreate(string path, PurePathFactoryOptions options, out IPurePath result)
        {
            result = null;
            switch (PlatformChooser.GetPlatform())
            {
            case Platform.Posix:
                PurePosixPath purePosixPath;
                if (PurePosixPath.TryParse(path, out purePosixPath))
                {
                    result = purePosixPath;
                    break;
                }
                return(false);

            case Platform.Windows:
                PureWindowsPath pureWindowsPath;
                if (PureWindowsPath.TryParse(path, out pureWindowsPath))
                {
                    result = pureWindowsPath;
                    break;
                }
                return(false);
            }
            result = ApplyOptions(result, options);
            return(true);
        }
Example #2
0
 private static IPurePath ApplyOptions(IPurePath path, PurePathFactoryOptions options)
 {
     if (options.AutoNormalizeCase)
     {
         path = options.Culture != null
             ? path.NormCase(options.Culture)
             : path.NormCase();
     }
     return(path);
 }
Example #3
0
 /// <summary>
 /// Factory method to create a new <see cref="PurePath"/> instance
 /// based upon the current operating system.
 /// </summary>
 /// <param name="path"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public IPurePath Create(string path, PurePathFactoryOptions options)
 {
     IPurePath ret = null;
     switch (PlatformChooser.GetPlatform())
     {
         case Platform.Posix:
             ret = new PurePosixPath(path);
             break;
         case Platform.Windows:
             ret =  new PureWindowsPath(path);
             break;
     }
     return ApplyOptions(ret, options);
 }
Example #4
0
        /// <summary>
        /// Factory method to create a new <see cref="PurePath"/> instance
        /// based upon the current operating system.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public IPurePath Create(string path, PurePathFactoryOptions options)
        {
            IPurePath ret = null;

            switch (PlatformChooser.GetPlatform())
            {
            case Platform.Posix:
                ret = new PurePosixPath(path);
                break;

            case Platform.Windows:
                ret = new PureWindowsPath(path);
                break;
            }
            return(ApplyOptions(ret, options));
        }
Example #5
0
 static PurePath()
 {
     FactoryOptions = new PurePathFactoryOptions();
 }
Example #6
0
 static PurePath()
 {
     FactoryOptions = new PurePathFactoryOptions();
 }
Example #7
0
 /// <summary>
 /// Factory method to create a new <see cref="PurePath"/> instance
 /// based upon the current operating system.
 /// </summary>
 /// <param name="path"></param>
 /// <param name="options"></param>
 /// <param name="result"></param>
 /// <returns></returns>
 public bool TryCreate(string path, PurePathFactoryOptions options, out IPurePath result)
 {
     result = null;
     switch (PlatformChooser.GetPlatform())
     {
         case Platform.Posix:
             PurePosixPath purePosixPath;
             if (PurePosixPath.TryParse(path, out purePosixPath))
             {
                 result = purePosixPath;
                 break;
             }
             return false;
         case Platform.Windows:
             PureWindowsPath pureWindowsPath;
             if (PureWindowsPath.TryParse(path, out pureWindowsPath))
             {
                 result = pureWindowsPath;
                 break;
             }
             return false;
     }
     result = ApplyOptions(result, options);
     return true;
 }
Example #8
0
 private static IPurePath ApplyOptions(IPurePath path, PurePathFactoryOptions options)
 {
     if (options.AutoNormalizeCase)
     {
         path = options.Culture != null
             ? path.NormCase(options.Culture)
             : path.NormCase();
     }
     return path;
 }