mirror of https://github.com/abpframework/abp.git
14 changed files with 165 additions and 32 deletions
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
[HtmlTargetElement("abp-bundle-contributor", TagStructure = TagStructure.NormalOrSelfClosing, ParentTag = "abp-style-bundle")] |
|||
[HtmlTargetElement("abp-bundle-contributor", TagStructure = TagStructure.NormalOrSelfClosing, ParentTag = "abp-script-bundle")] |
|||
public class AbpBundleContributorTagHelper : AbpTagHelper<AbpBundleContributorTagHelper, AbpBundleContributorTagHelperService> |
|||
{ |
|||
public Type Type { get; set; } |
|||
|
|||
public AbpBundleContributorTagHelper(AbpBundleContributorTagHelperService service) |
|||
: base(service) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.Collections.Generic; |
|||
using Microsoft.AspNetCore.Razor.TagHelpers; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public class AbpBundleContributorTagHelperService : AbpTagHelperService<AbpBundleContributorTagHelper> |
|||
{ |
|||
public override void Process(TagHelperContext context, TagHelperOutput output) |
|||
{ |
|||
output.SuppressOutput(); |
|||
|
|||
var files = (List<BundleTagHelperItem>)context.Items[AbpTagHelperConsts.ContextBundleItemListKey]; |
|||
files.Add(new BundleTagHelperItem(TagHelper.Type)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public static class AbpTagHelperConsts |
|||
{ |
|||
public const string ContextBundleItemListKey = "AbpBundleFileTagHelperService.BundleFiles"; |
|||
} |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers |
|||
{ |
|||
public class BundleTagHelperItem |
|||
{ |
|||
public string File { get; } |
|||
|
|||
public Type Type { get; } |
|||
|
|||
public BundleTagHelperItem(string file) |
|||
{ |
|||
File = file; |
|||
} |
|||
|
|||
public BundleTagHelperItem(Type type) |
|||
{ |
|||
Type = type; |
|||
} |
|||
|
|||
public override string ToString() |
|||
{ |
|||
return File ?? Type.FullName ?? "?"; |
|||
} |
|||
|
|||
public void AddToConfiguration(BundleConfiguration configuration) |
|||
{ |
|||
if (File != null) |
|||
{ |
|||
configuration.AddFiles(File); |
|||
} |
|||
else if (Type != null) |
|||
{ |
|||
configuration.AddContributors(Type); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling |
|||
{ |
|||
public interface IWebRequestResources |
|||
{ |
|||
/// <summary>
|
|||
/// Adds resouces to to current web request except the ones added before.
|
|||
/// </summary>
|
|||
/// <param name="resources">Candidate resources to be added</param>
|
|||
/// <returns>Resources actually added</returns>
|
|||
List<string> TryAdd(IEnumerable<string> resources); |
|||
|
|||
bool TryAdd(string resource); |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.UI.Resources |
|||
{ |
|||
public class WebRequestResources : IWebRequestResources, IScopedDependency |
|||
{ |
|||
protected List<string> Resources { get; } |
|||
|
|||
public WebRequestResources() |
|||
{ |
|||
Resources = new List<string>(); |
|||
} |
|||
|
|||
public virtual List<string> TryAdd(IEnumerable<string> resources) |
|||
{ |
|||
var newFiles = resources.Except(Resources).ToList(); |
|||
Resources.AddRange(newFiles); |
|||
return newFiles; |
|||
} |
|||
|
|||
public bool TryAdd(string resource) |
|||
{ |
|||
return Resources.AddIfNotContains(resource); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue