예제 #1
0
        public static string RegisterScriptBundle(
            this IClientScriptRegistry clientScriptRegistry,
            HttpContextBase httpContext,
            string bundleUrl,
            IEnumerable <string> urls,
            IEnumerable <string> sharedDependencies = null)
        {
            if (urls == null || !urls.Any())
            {
                return(string.Empty);
            }

            // Enforce the provided ordering within a registration
            // by making each item in the bundle depend on the previous.
            var    resources = new List <ClientScriptResource>();
            string lastUrl   = null;

            foreach (var url in urls)
            {
                resources.Add(new BundledScriptReferenceClientResource(
                                  url,
                                  bundleUrl,
                                  new[] { lastUrl }.Concat(sharedDependencies ?? Enumerable.Empty <string>())));

                lastUrl = url;
            }

            var output = clientScriptRegistry.Register(httpContext, resources);

            return(string.Concat(output));
        }
예제 #2
0
 public ContentSegmentContext(TokenExecutor tokenExecutor, IClientScriptRegistry clientScriptRegistry, HttpContextBase httpContext, Customer customer)
 {
     TokenExecutor        = tokenExecutor;
     ClientScriptRegistry = clientScriptRegistry;
     HttpContext          = httpContext;
     Customer             = customer;
 }
예제 #3
0
        public static string RegisterInlineScript(
            this IClientScriptRegistry clientScriptRegistry,
            HttpContextBase httpContext,
            string content,
            string name       = null,
            bool addScriptTag = false,
            IEnumerable <string> dependencies = null)
        {
            if (string.IsNullOrWhiteSpace(content))
            {
                return(string.Empty);
            }

            var resource = new InlineScriptClientResource(
                content: content,
                name: name,
                addScriptTag: addScriptTag,
                requirements: dependencies);

            var output = clientScriptRegistry.Register(
                httpContext,
                new[] { resource });

            return(string.Concat(output));
        }
예제 #4
0
        string GetAdMarkup(IClientScriptRegistry clientScriptRegistry, string dimensions, string publisherId, string dimensionsConfig)
        {
            if (string.IsNullOrEmpty(dimensionsConfig) || !dimensionsConfig.Contains(dimensions))
            {
                throw new ArgumentException("Ad dimensions must be in the list of allowable dimensions.");
            }

            var script = new StringBuilder();

            script.Append("<script type=\"text/javascript\">");
            script.Append("	(function (d, t) {\"use strict\";");
            script.Append("	var s = d.getElementsByTagName(t)[0], n = d.createElement(t);");
            script.Append("	n.src = \"//paypal.adtag.where.com/merchant.js\";");
            script.Append("	s.parentNode.insertBefore(n, s);");
            script.Append("}(document, \"script\"));");
            script.Append("</script>");

            var markup = new StringBuilder();

            markup.Append("<div class=\"paypal-banner-wrap\" >");
            markup.AppendFormat("<script type=\"text/javascript\" data-pp-pubid=\"{0}\" data-pp-placementtype=\"{1}\" data-pp-channel=\"vortx\"></script>", publisherId, dimensions);
            markup.Append(clientScriptRegistry.RegisterInlineScript(new HttpContextWrapper(HttpContext.Current), script.ToString()));
            markup.Append("</div>");

            return(markup.ToString());
        }
        public PaymentOptionProvider(UrlHelper urlHelper, IPaymentMethodInfoProvider paymentMethodInfoProvider, IClientScriptRegistry clientScriptRegistry)
        {
            UrlHelper = urlHelper;
            PaymentMethodInfoProvider = paymentMethodInfoProvider;
            ClientScriptRegistry      = clientScriptRegistry;

            PaymentOptionOrdering = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase)
            {
                { AppLogic.ro_PMPayPalExpress, 0 },
                { AppLogic.ro_PMPayPalCredit, 1 },
                { AppLogic.ro_PMCreditCard, 2 },
                { AppLogic.ro_PMPayPalEmbeddedCheckout, 3 },
                { AppLogic.ro_PMRequestQuote, 4 },
                { AppLogic.ro_PMPurchaseOrder, 5 },
                { AppLogic.ro_PMCheckByMail, 6 },
                { AppLogic.ro_PMCOD, 7 },
                { AppLogic.ro_PMMicropay, 8 },
            };

            OffsitePaymentOptionsForDisplay = new[]
            {
                AppLogic.ro_PMPayPalExpress,
                AppLogic.ro_PMAmazonPayments,
                AppLogic.ro_PMPayPalCredit
            };

            EditablePaymentOptions = new[]
            {
                AppLogic.ro_PMCreditCard,
                AppLogic.ro_PMPurchaseOrder
            };
        }
예제 #6
0
        public static string RegisterScriptReference(
            this IClientScriptRegistry clientScriptRegistry,
            HttpContextBase httpContext,
            string url,
            bool async = false,
            IEnumerable <string> dependencies = null)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                return(string.Empty);
            }

            var resource = new ScriptReferenceClientResource(url, async, dependencies);

            var output = clientScriptRegistry.Register(
                httpContext,
                new[] { resource });

            return(string.Concat(output));
        }
예제 #7
0
 public Parser()
 {
     DefaultTokenExecutor = DependencyResolver.Current.GetService <TokenExecutor>();
     ClientScriptRegistry = DependencyResolver.Current.GetService <IClientScriptRegistry>();
 }
예제 #8
0
 public BuySafeSeal(IClientScriptRegistry clientScriptRegistry, Func <HttpContextBase> httpContextFactory)
 {
     ClientScriptRegistry = clientScriptRegistry;
     HttpContextFactory   = httpContextFactory;
 }