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()); }
public string GetContent(ContentSegmentContext context) { return(context .TokenExecutor .GetTokenValue( context.Customer, Name, Parameters)); }
public string GetContent(ContentSegmentContext context) { return(context .ClientScriptRegistry .RegisterScriptReference( context.HttpContext, Url, Async, Dependencies)); }
public string GetContent(ContentSegmentContext context) { return(context .ClientScriptRegistry .RegisterScriptBundle( context.HttpContext, BundleUrl, new[] { Url }, Dependencies)); }
public string GetContent(ContentSegmentContext context) { return(context .ClientScriptRegistry .RegisterInlineScript( context.HttpContext, Content.GetContent(context), Name, addScriptTag: true, dependencies: Dependencies)); }
public string GetContent(ContentSegmentContext context) { return(Content); }
public string GetContent(ContentSegmentContext context) { return(string.Concat( Children.Select(child => child.GetContent(context)))); }