public bool TryChainUp(IFileSystemResourceAccessor potentialBaseResourceAccessor, string path, out IFileSystemResourceAccessor resultResourceAccessor)
        {
            resultResourceAccessor = null;
            string resourcePathName = potentialBaseResourceAccessor.ResourcePathName;

            if (string.IsNullOrEmpty(resourcePathName) || !potentialBaseResourceAccessor.IsFile ||
                !".zip".Equals(DosPathHelper.GetExtension(resourcePathName), StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            lock (_syncObj)
            {
                string key = potentialBaseResourceAccessor.CanonicalLocalResourcePath.Serialize();
                try
                {
                    ZipResourceProxy proxy;
                    if (!_zipUsages.TryGetValue(key, out proxy))
                    {
                        _zipUsages.Add(key, proxy = CreateZipResourceProxy(key, potentialBaseResourceAccessor));
                    }
                    resultResourceAccessor = new ZipResourceAccessor(this, proxy, path);
                }
                catch (Exception e)
                {
                    ServiceRegistration.Get <ILogger>().Warn("ZipResourceProvider: Error chaining up to '{0}'", e, potentialBaseResourceAccessor.CanonicalLocalResourcePath);
                    return(false);
                }
                return(true);
            }
        }
        public bool IsResource(IFileSystemResourceAccessor baseResourceAccessor, string path)
        {
            string entryPath = ZipResourceAccessor.ToEntryPath(path);

            lock (_syncObj)
            {
                string key = baseResourceAccessor.CanonicalLocalResourcePath.Serialize();
                try
                {
                    ZipResourceProxy proxy;
                    if (_zipUsages.TryGetValue(key, out proxy))
                    {
                        return(path.Equals("/") || ZipResourceAccessor.IsResource(proxy.ZipFile, entryPath));
                    }
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            using (Stream resourceStream = baseResourceAccessor.OpenRead()) // Not sure if the ZipFile will close the stream so we dispose it here
                try
                {
                    using (ZipFile zFile = new ZipFile(resourceStream))
                        return(path.Equals("/") || ZipResourceAccessor.IsResource(zFile, entryPath));
                }
                catch (Exception)
                {
                    return(false);
                }
        }
    public bool TryChainUp(IFileSystemResourceAccessor potentialBaseResourceAccessor, string path, out IFileSystemResourceAccessor resultResourceAccessor)
    {
      resultResourceAccessor = null;
      string resourcePathName = potentialBaseResourceAccessor.ResourcePathName;
      if (string.IsNullOrEmpty(resourcePathName) || !potentialBaseResourceAccessor.IsFile ||
          !".zip".Equals(DosPathHelper.GetExtension(resourcePathName), StringComparison.OrdinalIgnoreCase))
        return false;

      lock (_syncObj)
      {
        string key = potentialBaseResourceAccessor.CanonicalLocalResourcePath.Serialize();
        try
        {
          ZipResourceProxy proxy;
          if (!_zipUsages.TryGetValue(key, out proxy))
            _zipUsages.Add(key, proxy = CreateZipResourceProxy(key, potentialBaseResourceAccessor));
          resultResourceAccessor = new ZipResourceAccessor(this, proxy, path);
        }
        catch (Exception e)
        {
          ServiceRegistration.Get<ILogger>().Warn("ZipResourceProvider: Error chaining up to '{0}'", e, potentialBaseResourceAccessor.CanonicalLocalResourcePath);
          return false;
        }
        return true;
      }
    }