33using System . Collections . Generic ;
44using System . Linq ;
55using Microsoft . Extensions . FileSystemGlobbing ;
6+ using Microsoft . Extensions . Logging ;
67
78namespace WebOptimizer
89{
910 internal class AssetPipeline : IAssetPipeline
1011 {
1112 internal ConcurrentDictionary < string , IAsset > _assets = new ConcurrentDictionary < string , IAsset > ( StringComparer . OrdinalIgnoreCase ) ;
12-
13+ /// <summary>
14+ /// For use by the Asset constructor only. Do not use for logging messages inside <see cref="AssetPipeline"/>.
15+ /// </summary>
16+ internal ILogger < Asset > _assetLogger ;
1317 public IReadOnlyList < IAsset > Assets => _assets . Values . ToList ( ) ;
1418
1519 public bool TryGetAssetFromRoute ( string route , out IAsset asset )
@@ -52,10 +56,10 @@ public bool TryGetAssetFromRoute(string route, out IAsset asset)
5256
5357 if ( result . HasMatches )
5458 {
55- asset = new Asset ( cleanRoute , existing . ContentType , this , new [ ]
59+ asset = new Asset ( cleanRoute , existing . ContentType , new [ ]
5660 {
5761 cleanRoute
58- } ) ;
62+ } , _assetLogger ) ;
5963
6064 foreach ( IProcessor processor in existing . Processors )
6165 {
@@ -113,7 +117,7 @@ public IAsset AddBundle(string route, string contentType, params string[] source
113117
114118 route = NormalizeRoute ( route ) ;
115119
116- IAsset asset = new Asset ( route , contentType , this , sourceFiles ) ;
120+ IAsset asset = new Asset ( route , contentType , sourceFiles , _assetLogger ) ;
117121 _assets . TryAdd ( route , asset ) ;
118122
119123 return asset ;
@@ -124,7 +128,7 @@ public IAsset AddAsset(string route, string contentType)
124128 {
125129 route = NormalizeRoute ( route ) ;
126130
127- IAsset asset = new Asset ( route , contentType , this , new string [ 0 ] ) ;
131+ IAsset asset = new Asset ( route , contentType , new string [ 0 ] , _assetLogger ) ;
128132 _assets . TryAdd ( route , asset ) ;
129133
130134 return asset ;
@@ -146,7 +150,7 @@ public IEnumerable<IAsset> AddFiles(string contentType, params string[] sourceFi
146150
147151 foreach ( string file in sourceFiles )
148152 {
149- IAsset asset = new Asset ( NormalizeRoute ( file ) , contentType , this , new [ ] { file } ) ;
153+ IAsset asset = new Asset ( NormalizeRoute ( file ) , contentType , [ file ] , _assetLogger ) ;
150154 list . Add ( asset ) ;
151155 _assets . TryAdd ( asset . Route , asset ) ;
152156 }
@@ -167,13 +171,13 @@ public static string NormalizeRoute(string route)
167171 {
168172 cleanRoute = cleanRoute . Substring ( 0 , index ) ;
169173 }
170-
171- if ( ! cleanRoute . StartsWith ( "/" ) )
174+
175+ if ( ! cleanRoute . StartsWith ( "/" ) )
172176 {
173177 cleanRoute = "/" + cleanRoute ;
174178 }
175179
176180 return cleanRoute ;
177181 }
178182 }
179- }
183+ }
0 commit comments