コード例 #1
0
 internal void UpdateCache(VfsDirectoryInfo info)
 {
     string key = info.FullName.TrimEnd('\\');
     lock (_directories)
     {
         _directories[key] = info;
     }
 }
コード例 #2
0
        internal void UpdateCache(VfsDirectoryInfo info)
        {
            string key = info.FullName.TrimEnd('\\');

            lock (_directories)
            {
                _directories[key] = info;
            }
        }
コード例 #3
0
 public DirectoryInfoBase FromDirectoryName(string directoryName)
 {
     string key = directoryName.TrimEnd('\\');
     VfsDirectoryInfo result;
     lock (_directories)
     {
         if (!_directories.TryGetValue(key, out result))
         {
             _directories[key] = result = new VfsDirectoryInfo(_fileSystem, new DirectoryInfo(directoryName));
         }
     }
     return result;
 }
コード例 #4
0
        public DirectoryInfoBase FromDirectoryName(string directoryName)
        {
            string           key = directoryName.TrimEnd('\\');
            VfsDirectoryInfo result;

            lock (_directories)
            {
                if (!_directories.TryGetValue(key, out result))
                {
                    _directories[key] = result = new VfsDirectoryInfo(_fileSystem, new DirectoryInfo(directoryName));
                }
            }
            return(result);
        }
コード例 #5
0
ファイル: VfsDirectoryInfo.cs プロジェクト: radtek/KuduVfs
        private FileSystemInfoBase[] GetFileSystemInfosInternal()
        {
            if (_infos == null)
            {
                using (var client = VfsUtils.NewHttpClient(_href, _fileSystem._creds))
                {
                    using (HttpResponseMessage response = client.GetAsync(_href.AbsolutePath).Result)
                    {
                        if (response.StatusCode == HttpStatusCode.NotFound)
                        {
                            throw new DirectoryNotFoundException(this.FullName + " does not exists.");
                        }

                        response.EnsureSuccessful();

                        if (response.Content.Headers.ContentType.MediaType != "application/json")
                        {
                            throw new IOException("The directory name is invalid.");
                        }

                        var array = response.Content.ReadAsAsync <VfsJsonFileSystemInfo[]>().Result;
                        _infos = array.Select(json =>
                        {
                            FileSystemInfoBase info;
                            if (json.Mime == "inode/directory")
                            {
                                info = new VfsDirectoryInfo(_fileSystem, json);
                            }
                            else
                            {
                                info = new VfsFileInfo(_fileSystem, json);
                            }
                            return(info);
                        }).ToArray();
                    }
                }
            }

            return(_infos);
        }
コード例 #6
0
        private FileSystemInfoBase[] GetFileSystemInfosInternal()
        {
            if (_infos == null)
            {
                using (var client = VfsUtils.NewHttpClient(_href, _fileSystem._creds))
                {
                    using (HttpResponseMessage response = client.GetAsync(_href.AbsolutePath).Result)
                    {
                        if (response.StatusCode == HttpStatusCode.NotFound)
                        {
                            throw new DirectoryNotFoundException(this.FullName + " does not exists.");
                        }

                        response.EnsureSuccessful();

                        if (response.Content.Headers.ContentType.MediaType != "application/json")
                        {
                            throw new IOException("The directory name is invalid.");
                        }

                        var array = response.Content.ReadAsAsync<VfsJsonFileSystemInfo[]>().Result;
                        _infos = array.Select(json =>
                        {
                            FileSystemInfoBase info;
                            if (json.Mime == "inode/directory")
                            {
                                info = new VfsDirectoryInfo(_fileSystem, json);
                            }
                            else
                            {
                                info = new VfsFileInfo(_fileSystem, json);
                            }
                            return info;
                        }).ToArray();
                    }
                }
            }

            return _infos;
        }