Exemplo n.º 1
0
        protected void AddToCache(ProviderModel provider, DirectoryModel directory)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }

            var hash = provider.GetHashCode();

            if (!string.IsNullOrEmpty(directory.Path))
            {
                hash += directory.Path.GetHashCode();
            }

            _cache.Set(hash, directory);
        }
Exemplo n.º 2
0
        protected DirectoryModel GetFromCache(ProviderModel provider, string path)
        {
            var hash = provider.GetHashCode();

            if (!string.IsNullOrEmpty(path))
            {
                hash += path.GetHashCode();
            }

            if (_cache.TryGetValue(hash, out DirectoryModel directory))
            {
                return(directory);
            }

            return(null);
        }
Exemplo n.º 3
0
        protected DirectoryModel GetFromCache(ProviderModel provider, string path)
        {
            var hash = provider.GetHashCode();

            if (!string.IsNullOrEmpty(path))
            {
                hash += path.GetHashCode();
            }

            if (_cache.ContainsKey(hash))
            {
                return(_cache[hash]);
            }

            return(null);
        }
Exemplo n.º 4
0
        protected void AddToCache(ProviderModel provider, DirectoryModel directory)
        {
            if (directory == null)
            {
                throw new ArgumentNullException(nameof(directory));
            }

            var hash = provider.GetHashCode();

            if (!string.IsNullOrEmpty(directory.Path))
            {
                hash += directory.Path.GetHashCode();
            }

            if (_cache.ContainsKey(hash))
            {
                _cache[hash] = directory;
            }
            else
            {
                _cache.Add(hash, directory);
            }
        }