Пример #1
0
        public string ReplaceTokens(HttpContextBase httpContext, Customer customer, string unparsedInput, ParserOptions options = null)
        {
            // Initialize default options if none are provided
            options = options ?? new ParserOptions();

            var registeredTokenHandlers = DependencyResolver.Current.GetServices <ITokenHandler>();
            var tokenExecutorFactory    = DependencyResolver.Current.GetService <TokenExecutorFactory>();
            var tokenExecutor           = tokenExecutorFactory(registeredTokenHandlers.Concat(options.AdditionalTokenHandlers));

            // Parse the input document and get the parsed content segments and any unparsed results back
            var parser       = BuildParser();
            var parserResult = parser.TryParse(unparsedInput);

            // Evaluate and combine the content segments
            var content = new StringBuilder();
            var context = new ContentSegmentContext(tokenExecutor, ClientScriptRegistry, httpContext, httpContext.GetCustomer());

            foreach (var segment in parserResult.Value)
            {
                content.Append(segment.GetContent(context));
            }

            // Append any remainder of the input that failed to parse
            if (!parserResult.Remainder.AtEnd)
            {
                content.Append(parserResult.Remainder.Source.Substring(parserResult.Remainder.Position));
            }

            return(content.ToString());
        }
Пример #2
0
 public string GetContent(ContentSegmentContext context)
 {
     return(context
            .TokenExecutor
            .GetTokenValue(
                context.Customer,
                Name,
                Parameters));
 }
Пример #3
0
 public string GetContent(ContentSegmentContext context)
 {
     return(context
            .ClientScriptRegistry
            .RegisterScriptReference(
                context.HttpContext,
                Url,
                Async,
                Dependencies));
 }
Пример #4
0
 public string GetContent(ContentSegmentContext context)
 {
     return(context
            .ClientScriptRegistry
            .RegisterScriptBundle(
                context.HttpContext,
                BundleUrl,
                new[] { Url },
                Dependencies));
 }
Пример #5
0
 public string GetContent(ContentSegmentContext context)
 {
     return(context
            .ClientScriptRegistry
            .RegisterInlineScript(
                context.HttpContext,
                Content.GetContent(context),
                Name,
                addScriptTag: true,
                dependencies: Dependencies));
 }
Пример #6
0
 public string GetContent(ContentSegmentContext context)
 {
     return(Content);
 }
Пример #7
0
 public string GetContent(ContentSegmentContext context)
 {
     return(string.Concat(
                Children.Select(child => child.GetContent(context))));
 }