mirror of https://github.com/abpframework/abp.git
9 changed files with 98 additions and 54 deletions
@ -1,16 +0,0 @@ |
|||||
using System.Collections.Generic; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.Mvc.UI.Resources |
|
||||
{ |
|
||||
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,19 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Resources |
||||
|
{ |
||||
|
public interface IWebRequestResources |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Filters given resources and returns a list of resources those are not
|
||||
|
/// added to the page for current web request.
|
||||
|
/// </summary>
|
||||
|
List<string> Filter(IEnumerable<string> resources); |
||||
|
|
||||
|
bool IsAddedBefore(string resource); |
||||
|
|
||||
|
void Add(IEnumerable<string> resources); |
||||
|
|
||||
|
IReadOnlyList<string> GetAll(); |
||||
|
} |
||||
|
} |
||||
@ -1,29 +0,0 @@ |
|||||
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); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,40 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.Immutable; |
||||
|
using System.Linq; |
||||
|
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 List<string> Filter(IEnumerable<string> resources) |
||||
|
{ |
||||
|
return resources.Except(Resources).ToList(); |
||||
|
} |
||||
|
|
||||
|
public bool IsAddedBefore(string resource) |
||||
|
{ |
||||
|
return Resources.Contains(resource); |
||||
|
} |
||||
|
|
||||
|
public void Add(IEnumerable<string> resources) |
||||
|
{ |
||||
|
foreach (var resource in resources) |
||||
|
{ |
||||
|
Resources.AddIfNotContains(resource); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public IReadOnlyList<string> GetAll() |
||||
|
{ |
||||
|
return Resources.ToImmutableList(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue