asp.net mvc - Include a sorted bundle to another bundle -


i trying create bundle's can make single request render required .css , .js files

method order bundle

using this post

public class asisbundleorderer : ibundleorderer {     public virtual ienumerable<fileinfo> orderfiles(bundlecontext context, ienumerable<fileinfo> files)     {         return files;     } } 

method make composable bundle

using this post

public class composablebundle<t> t : bundle {     private t _bundle;     private list<string> _virtualpaths = new list<string>();      public composablebundle(t bundle)     {         _bundle = bundle;     }      public string[] virtualpaths     {         { return _virtualpaths.toarray(); }     }      public t bundle     {         { return _bundle; }     }      public composablebundle<t> include(params string[] virtualpaths)     {         _virtualpaths.addrange(virtualpaths);         _bundle.include(virtualpaths);         return this;     }      public composablebundle<t> usebundle(composablebundle<t> bundle)     {         _bundle.include(bundle.virtualpaths.toarray());         return this;     } }  public static class bundleextensions {     public static composablebundle<t> ascomposable<t>(this t bundle) t : bundle     {         return new composablebundle<t>(bundle);     }      public static composablebundle<t> add<t>(this bundlecollection bundles, composablebundle<t> bundle) t: bundle     {         bundles.add(bundle.bundle);         return bundle;     } } 

i have common .css , .js used site layout , have used this:

layout bundle

i using bundel orderer order files

 var layoutcss = new stylebundle("~/bundles/layout/css");  layoutcss.orderer = new asisbundleorderer();  layoutcss.ascomposable()                .include("~/content/bootstrap.min.css")                .include("~/content/font-awesome.min.css")                .include("~/content/site.css");  bundles.add(layoutcss); 

home page bundle

here including common layout bundle home page bundle , dont repeat myself use .include again

var homecss = new stylebundle("~/bundles/home/css"); homecss.orderer = new asisbundleorderer(); homecss. ascomposable().usebundle(layoutcss)               .include("~/content/home.css"); bundles.add(homecss); 

error:

cannot convert 'system.web.optimization.stylebundle' 'helloworldmvcproject.composablebundle'

i able order bundle, how can use usebundle method ?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -