/// <inheritdoc />
        internal override Func <HttpContext, string> CreateBuilder()
        {
            if (BlockResources)
            {
                return(ctx => GetPolicy("'none'"));
            }

            var sources = string.Join(Separator, Sources);

            if (!HasPerRequestValues)
            {
                var directive = GetPolicy(sources);
                return(ctx => directive);
            }

            var builders = SourceBuilders;

            if (!string.IsNullOrEmpty(sources))
            {
                // Copy, so calls to CreateBuilder are idempotent
                builders = SourceBuilders.ToList();

                // insert the constant sources first, just for aesthetics
                builders.Insert(0, ctx => sources);
            }

            return(ctx =>
            {
                var dynamicSources = builders
                                     .Select(builder => builder.Invoke(ctx))
                                     .Where(str => !string.IsNullOrEmpty(str));
                return GetPolicy(string.Join(Separator, dynamicSources));
            });
        }
 /// <summary>
 /// Allow sources for content generated using the the HashTagHelper.
 /// </summary>
 /// <returns>The CSP builder for method chaining</returns>
 public StyleSourceDirectiveBuilder WithHashTagHelper()
 {
     // TODO: check hash algorithm is one of expected values
     SourceBuilders.Add(ctx =>
     {
         return(string.Join(" ", ctx.GetStyleCSPHashes()));
     });
     return(this);
 }