protected virtual IEnumerable <string> ResolveAssetPaths(IControlOutputContext context)
        {
            IAssetProvider assetProvider = (context.Control as IAssetProvider) ?? (context.Children.FirstOrDefault()?.Control as IAssetProvider);

            if (null == assetProvider)
            {
                yield break;
            }

            var extensions = assetProvider.GetAssetFileExtensions();

            if (null == extensions)
            {
                yield break;
            }

            extensions = extensions.Distinct();

            foreach (var extension in extensions)
            {
                var paths = assetProvider.GetAssetPaths(extension);

                if (null == paths)
                {
                    yield break;
                }

                foreach (var path in paths)
                {
                    yield return(path);
                }
            }
        }
Beispiel #2
0
        protected virtual IEnumerable <string> ResolveAssetPaths(IControlOutputContext context)
        {
            IAssetProvider assetProvider = (context.Control as IAssetProvider) ?? (context.Children.FirstOrDefault()?.Control as IAssetProvider);

            if (null == assetProvider)
            {
                yield break;
            }

            var extensions = assetProvider.GetAssetFileExtensions();

            if (null == extensions)
            {
                yield break;
            }

            extensions = extensions.Distinct();

            foreach (var extension in extensions)
            {
                var paths = assetProvider.GetAssetPaths(extension);

                if (null == paths)
                {
                    yield break;
                }

                foreach (var path in paths)
                {
                    if (null == path)
                    {
                        throw new ArgumentNullException($"Null resource path specified in web control '{context.Control?.GetType().FullName}'.");
                    }

                    if (Uri.TryCreate(path, UriKind.Absolute, out Uri tempUri))
                    {
                        yield return(path);
                    }
                    else
                    {
                        yield return($"{this.WebControlsOptions.AssetsRootPath.Value.TrimEnd('/')}/{path.TrimStart('/')}");
                    }
                }
            }
        }