public IDirectoryContents GetDirectoryContents(string subpath)
        {
            if (subpath == null)
            {
                return(new NotFoundDirectoryContents());
            }

            var resourcePath = subpath.Replace("-", "_")
                               .Replace("~/", "")
                               .Replace("/", ".")
                               .Replace("\\", ".")
                               .Trim(new char[] { '.' });

            var allFiles = _embeddedFileProvider
                           .GetDirectoryContents(string.Empty)
                           .Where(f => f.Name.StartsWith(resourcePath, StringComparison.OrdinalIgnoreCase))
            ;

            if (!allFiles.Any())
            {
                return(new NotFoundDirectoryContents());
            }

            var directoryContents = new EmbeddedDirectoryContents(resourcePath, allFiles);

            return(directoryContents);
        }
Exemplo n.º 2
0
        public IDirectoryContents GetDirectoryContents(string subpath)
        {
            if (subpath == null)
            {
                return(new NotFoundDirectoryContents());
            }

            var resourcePath = EmbeddedResourcePathFormatter.ConvertFromVirtualDirectory(subpath);

            var allFiles = _embeddedFileProvider
                           .GetDirectoryContents(string.Empty)
                           .Where(f => f.Name.StartsWith(resourcePath, StringComparison.OrdinalIgnoreCase))
            ;

            if (!allFiles.Any())
            {
                return(new NotFoundDirectoryContents());
            }

            var directoryContents = new EmbeddedDirectoryContents(resourcePath, allFiles);

            return(directoryContents);
        }