Exemplo 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);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Factory method to create a new <see cref="PurePath"/> instance
        /// based upon the current operating system.
        /// </summary>
        /// <param name="options"></param>
        /// <param name="paths"></param>
        /// <returns></returns>
        public IPath Create(PathFactoryOptions options, params string[] paths)
        {
            IPath ret = null;

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

            case Platform.Windows:
                ret = new WindowsPath(paths);
                break;
            }
            return(ApplyOptions(ret, options));
        }