public FileProviderGlobbingDirectory(
        IFileProvider fileProvider,
        IFileInfo fileInfo,
        FileProviderGlobbingDirectory parent)
    {
        if (fileProvider == null)
        {
            throw new ArgumentNullException(nameof(fileProvider));
        }

        _fileProvider = fileProvider;
        _fileInfo     = fileInfo;
        _parent       = parent;

        if (_fileInfo == null)
        {
            // We're the root of the directory tree
            RelativePath = string.Empty;
            _isRoot      = true;
        }
        else if (!string.IsNullOrEmpty(parent?.RelativePath))
        {
            // We have a parent and they have a relative path so concat that with my name
            RelativePath = _parent.RelativePath + DirectorySeparatorChar + _fileInfo.Name;
        }
        else
        {
            // We have a parent which is the root, so just use my name
            RelativePath = _fileInfo.Name;
        }
    }
Exemple #2
0
    /// <summary>
    /// Creates a new <see cref="GlobbingUrlBuilder"/>.
    /// </summary>
    /// <param name="fileProvider">The file provider.</param>
    /// <param name="cache">The cache.</param>
    /// <param name="requestPathBase">The request path base.</param>
    public GlobbingUrlBuilder(IFileProvider fileProvider, IMemoryCache cache, PathString requestPathBase)
    {
        ArgumentNullException.ThrowIfNull(fileProvider);
        ArgumentNullException.ThrowIfNull(cache);

        FileProvider           = fileProvider;
        Cache                  = cache;
        RequestPathBase        = requestPathBase;
        _baseGlobbingDirectory = new FileProviderGlobbingDirectory(fileProvider, fileInfo: null, parent: null);
    }
Exemple #3
0
    /// <summary>
    /// Creates a new <see cref="GlobbingUrlBuilder"/>.
    /// </summary>
    /// <param name="fileProvider">The file provider.</param>
    /// <param name="cache">The cache.</param>
    /// <param name="requestPathBase">The request path base.</param>
    public GlobbingUrlBuilder(IFileProvider fileProvider, IMemoryCache cache, PathString requestPathBase)
    {
        if (fileProvider == null)
        {
            throw new ArgumentNullException(nameof(fileProvider));
        }

        if (cache == null)
        {
            throw new ArgumentNullException(nameof(cache));
        }

        FileProvider           = fileProvider;
        Cache                  = cache;
        RequestPathBase        = requestPathBase;
        _baseGlobbingDirectory = new FileProviderGlobbingDirectory(fileProvider, fileInfo: null, parent: null);
    }