Ignite.Assets.AssetResolver.GetAssets C# (CSharp) Méthode

GetAssets() public méthode

public GetAssets ( string appPath, IEnumerable included, IEnumerable excluded ) : IList
appPath string
included IEnumerable
excluded IEnumerable
Résultat IList
        public IList<IAsset> GetAssets(string appPath, IEnumerable<string> included, IEnumerable<string> excluded)
        {
            var paths = included
                .SelectMany(i => this.ResolvePath(appPath, i))
                .Distinct()
                .ToList();

            foreach (var e in excluded.SelectMany(e => this.ResolvePath(appPath, e)))
            {
                paths.Remove(e);
            }

            return paths.Select(p =>
            {
                var ap = p.Replace(appPath, "").Replace('\\', '/');
                return (IAsset)new Asset(ap, p, this.fileSystem);
            }).ToList();
        }

Usage Example

        public void Should_resolve_file_wildcards()
        {
            var fs = new Mock<IFileSystem>();
            fs.Setup(f => f.EnumerateFiles("C:\\app\\content\\scripts", "*.js", System.IO.SearchOption.TopDirectoryOnly))
                .Returns(new[] { "C:\\app\\content\\scripts\\1.js", "C:\\app\\content\\scripts\\2.js" });

            fs.Setup(f => f.EnumerateFiles("C:\\app\\content\\other", "*.js", System.IO.SearchOption.TopDirectoryOnly))
                .Returns(new[] { "C:\\app\\content\\other\\1.js" });

            var b = new AssetResolver(fs.Object);
            var result = b.GetAssets("C:\\app\\",
                new[]
                {
                    "content/scripts/*.js",
                    "content/other/*.js"
                },
                new[]
                {
                    "content/other/*.js"
                });

            Assert.AreEqual("content/scripts/1.js", result[0].Path);
            Assert.AreEqual("content/scripts/2.js", result[1].Path);
            Assert.AreEqual(2, result.Count);
        }
All Usage Examples Of Ignite.Assets.AssetResolver::GetAssets