Exemple #1
0
        internal FileUri(IFileSystemPlatform fileSystemPlatform, string uri)
        {
            _uri = uri;
            if (_uri == "/")
            {
                _uri = String.Empty;
            }

            if (String.IsNullOrWhiteSpace(_uri) ||
                !_uri.Contains("://"))
            {
                throw new InvalidOperationException(
                          "The URI you provide is invalid. Please provide an uri in this form 'location://relative/path/to/your/folder/or/file'");
            }

            string[] locations        = Enum.GetNames(typeof(StorageLocation));
            bool     hasValidLocation = false;

            foreach (string location in locations)
            {
                _root = String.Concat(location, "://").ToLower();

                if (uri.StartsWith(_root, StringComparison.OrdinalIgnoreCase))
                {
                    hasValidLocation = true;

                    _location =
                        (StorageLocation)Enum.Parse(typeof(StorageLocation), location);

                    break;
                }
            }

            if (!hasValidLocation)
            {
                throw new InvalidOperationException("The URI you provide is invalid.");
            }

            _relativePath = _uri.Substring(_root.Length, _uri.Length - _root.Length);
            _absolutePath = fileSystemPlatform.GetAbsolutePath(Location, _relativePath);
        }
Exemple #2
0
 public static void EnableFileSystem(IFileSystemPlatform fileSystemPlatform)
 {
     _filesystem = new FileSystem(fileSystemPlatform);
 }
Exemple #3
0
 internal FolderUri(IFileSystemPlatform fileSystemPlatform, string uri)
     : base(fileSystemPlatform, StripFileName(uri))
 {
 }
Exemple #4
0
 internal FolderUri(IFileSystemPlatform fileSystemPlatform, string path, StorageLocation location)
     : this(fileSystemPlatform, String.Concat(location.ToString().ToLower(), "://", path))
 {
 }
Exemple #5
0
 public FileSystem(IFileSystemPlatform fileSystemPlatform)
 {
     _fileSystemPlatform = fileSystemPlatform;
 }