예제 #1
0
        public void GivenLocationAlreadyRenderedButHtmlRewrittingEnabled_WhenAddReferenceToThatLocation_ThenBundleStillAdded()
        {
            builder = new ReferenceBuilder(
                bundleContainer.Object,
                bundleFactories, Mock.Of<IPlaceholderTracker>(),
                new CassetteSettings("") { IsHtmlRewritingEnabled = true }
            );
            var bundle = new ScriptBundle("~/test");
            bundleContainer.Setup(c => c.FindBundleContainingPath<Bundle>("~/test"))
                           .Returns(bundle);
            builder.Render<ScriptBundle>("test");

            builder.Reference("~/test", "test");

            builder.GetBundles("test").First().ShouldBeSameAs(bundle);
        }
예제 #2
0
        /// <summary>
        /// Get the URLs for bundles that have been referenced during the current request.
        /// </summary>
        /// <typeparam name="T">The type of bundles.</typeparam>
        /// <param name="pageLocation">Optional. The page location of bundles to return.</param>
        public static IEnumerable <string> GetReferencedBundleUrls <T>(string pageLocation)
            where T : Bundle
        {
            var bundles = ReferenceBuilder.GetBundles(pageLocation).OfType <T>();

            if (Application.Settings.IsDebuggingEnabled)
            {
                return(bundles
                       .SelectMany(GetAllAssets)
                       .Select(Application.Settings.UrlGenerator.CreateAssetUrl));
            }
            else
            {
                return(bundles
                       .Select(Application.Settings.UrlGenerator.CreateBundleUrl));
            }
        }
예제 #3
0
 /// <summary>
 /// Gets the bundles that have been referenced during the current request.
 /// </summary>
 /// <param name="pageLocation">Optional. The page location of bundles to return.</param>
 public static IEnumerable <Bundle> GetReferencedBundles(string pageLocation)
 {
     return(ReferenceBuilder.GetBundles(pageLocation));
 }