Beispiel #1
0
        public bool GetResponse(Uri uri, out IBundleContentResponse bundleContentResponse, out string requestVersion)
        {
            IBundle bundle;

            if (!Get(uri.AbsolutePath, out bundle))
            {
                bundleContentResponse = null;
                requestVersion        = null;
                return(false);
            }

            var response = bundle.GetResponse();

            var queryArgs = bundle.Context.UrlHelper.ParseQuery(uri.Query);

            queryArgs.TryGetValue(VersionQueryParameterName, out requestVersion);
            if (string.IsNullOrWhiteSpace(requestVersion))
            {
                requestVersion = null;
            }

            string requestFile;

            if (queryArgs.TryGetValue(FileQueryParameterName, out requestFile) && !string.IsNullOrWhiteSpace(requestFile))
            {
                return(response.Files.TryGetValue(requestFile, out bundleContentResponse));
            }

            bundleContentResponse = response;
            return(true);
        }
Beispiel #2
0
        private static string GenerateUrl(string virtualPath, IBundle bundle, IBundleContentResponse response, string fileName = null)
        {
            var fQuery = !string.IsNullOrWhiteSpace(fileName)
                ? $"{FileQueryParameterName}={bundle.Context.UrlHelper.Encode(fileName)}"
                : null;

            var vQuery = bundle.Context.Configuration.Get(BundlingConfiguration.IncludeContentHash)
                ? $"{VersionQueryParameterName}={bundle.Context.UrlHelper.Encode(response.ContentHash)}"
                : null;

            var queryArgs = string.Join("&", new[] {
                fQuery,
                vQuery
            }.Where(x => x != null));

            return(string.Join("?", bundle.Context.UrlHelper.ToAbsolute(virtualPath), queryArgs));
        }
Beispiel #3
0
 public AspNetBundlerHandler(IBundleContext bundleContext, IBundleContentResponse bundleContentResponse, string requestVersion)
 {
     _bundleContext         = bundleContext;
     _bundleContentResponse = bundleContentResponse;
     _requestVersion        = requestVersion;
 }