Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo 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);
            }
        }