void IGenerator.GetText(Scope scope, TextWriter writer, Scope context) { object value = _isVariable ? context.Find(_key, _shouldHtmlEscape) : scope.Find(_key, _shouldHtmlEscape); if (_shouldHtmlEscape) { writer.Write(_format, System.Net.WebUtility.HtmlEncode(value as string)); } else { writer.Write(_format, value); } }
void IGenerator.GetText(Scope scope, TextWriter writer, Scope context) { object value = _isVariable ? context.Find(_key) : scope.Find(_key); var formattable = value as IFormattable; if (formattable != null) { writer.Write(formattable.ToString(null, System.Threading.Thread.CurrentThread.CurrentCulture)); } else { writer.Write(value); } }
void IGenerator.GetText(TextWriter writer, Scope scope, Scope context, Action <Substitution> postProcessor) { object value = _isVariable ? context.Find(_key, _isExtension) : scope.Find(_key, _isExtension); string result = String.Format(writer.FormatProvider, _format, value); Substitution substitution = new Substitution() { Key = _key, Substitute = result, IsExtension = _isExtension }; postProcessor(substitution); writer.Write(substitution.Substitute); }
/// <summary> /// Substitutes the key placeholders with their respective values. /// </summary> /// <param name="keyScope">The key/value pairs in the current lexical scope.</param> /// <param name="contextScope">The key/value pairs in current context.</param> /// <returns>A dictionary associating the parameter name to the associated value.</returns> public Dictionary<string, object> GetArguments(Scope keyScope, Scope contextScope) { Dictionary<string, object> arguments = new Dictionary<string,object>(); foreach (KeyValuePair<TagParameter, string> pair in _argumentLookup) { object value; if (pair.Value == null) { value = pair.Key.DefaultValue; } else if (pair.Value.StartsWith("@")) { value = contextScope.Find(pair.Value.Substring(1)); } else { value = keyScope.Find(pair.Value); } arguments.Add(pair.Key.Name, value); } return arguments; }
/// <summary> /// Substitutes the key placeholders with their respective values. /// </summary> /// <param name="keyScope">The key/value pairs in the current lexical scope.</param> /// <param name="contextScope">The key/value pairs in current context.</param> /// <returns>A dictionary associating the parameter name to the associated value.</returns> public Dictionary <string, object> GetArguments(Scope keyScope, Scope contextScope) { Dictionary <string, object> arguments = new Dictionary <string, object>(); foreach (KeyValuePair <TagParameter, string> pair in _argumentLookup) { object value; if (pair.Value == null) { value = pair.Key.DefaultValue; } else if (pair.Value.StartsWith("@")) { value = contextScope.Find(pair.Value.Substring(1)); } else { value = keyScope.Find(pair.Value); } arguments.Add(pair.Key.Name, value); } return(arguments); }
public object GetValue(Scope keyScope, Scope contextScope) { return(keyScope.Find(name)); }
public object GetValue(Scope keyScope, Scope contextScope) { return contextScope.Find(name); }
void IGenerator.GetText(Scope scope, TextWriter writer, Scope context) { object value = _isVariable ? context.Find(_key) : scope.Find(_key); writer.Write(_format, value); }