-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added directory support #32
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace EmbeddedResourceVirtualPathProvider | ||
{ | ||
public class EmbeddedResourcePath | ||
{ | ||
public string Directory { get; set; } | ||
|
||
public string Filename { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Web.Hosting; | ||
|
||
namespace EmbeddedResourceVirtualPathProvider | ||
{ | ||
class EmbeddedResourceVirtualDirectory : VirtualDirectory | ||
{ | ||
Dictionary<string, List<EmbeddedResource>> _resources; | ||
Func<EmbeddedResource, EmbeddedResourceCacheControl> _cacheControl; | ||
|
||
public EmbeddedResourceVirtualDirectory(string virtualPath, Dictionary<string, List<EmbeddedResource>> resources, Func<EmbeddedResource, EmbeddedResourceCacheControl> cacheControl) : base(virtualPath) | ||
{ | ||
_resources = resources; | ||
_cacheControl = cacheControl; | ||
} | ||
|
||
public override IEnumerable Children | ||
{ | ||
get | ||
{ | ||
return Files; | ||
} | ||
} | ||
|
||
public override IEnumerable Directories | ||
{ | ||
get | ||
{ | ||
return new List<VirtualDirectory>(); | ||
} | ||
} | ||
|
||
public override IEnumerable Files | ||
{ | ||
get | ||
{ | ||
return _resources.Select(resource => new EmbeddedResourceVirtualFile(System.IO.Path.Combine(this.VirtualPath, resource.Key), resource.Value.FirstOrDefault(), _cacheControl(resource.Value.FirstOrDefault()))); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,5 +25,6 @@ public override Stream Open() | |
} | ||
return embedded.GetStream(); | ||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
alert("Scripts/alert-1.12.34567.min.js - works with more complex path") |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
<title></title> | ||
<script src="/alert.js" type="text/javascript"></script> | ||
<script src="/alert2.js" type="text/javascript"></script> | ||
<script src="/Scripts/alert.3.js" type="text/javascript"></script> | ||
<script src="/Scripts/alert-1.12.34567.min.js" type="text/javascript"></script> | ||
<script src="/3rd3Party/3select2-3.4.5/select2.js" type="text/javascript"></script> | ||
<script src="/3rd3Party/hammer.js-1.0.10/hammer.js" type="text/javascript"></script> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it works, Demo |
||
</head> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return
Files.Contat(Directories)
? A more general question - does this PR work with nested directories (I don't think you explicitly mentioned it, but I notice the test folder is a single directory)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should, but I did not implement sub-directories, so I left it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are subdirectories unnecessary for ASP.NET bundling, or will embedded resource bundling only work with single subdirectories?
Sorry for dumb questions but I don't use Bundles that much, and if there's any unexpected behaviour I'll need to document it to reduce the number of people raising Github Issues.