Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 5
0
 static PurePath()
 {
     FactoryOptions = new PurePathFactoryOptions();
 }
Ejemplo n.º 6
0
 static PurePath()
 {
     FactoryOptions = new PurePathFactoryOptions();
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }