public static PropertyValueTemplate AddProperty(this AnonymousObjectTemplate template, string name, ICodeFragment value = null) { PropertyValueTemplate propertyValueTemplate = new PropertyValueTemplate(name, value); template.Properties.Add(propertyValueTemplate); return(propertyValueTemplate); }
public virtual void Write(ICodeFragment fragment, IOutputCache output) { AnonymousObjectTemplate template = (AnonymousObjectTemplate)fragment; output.Add("{") .Indent(); PropertyValueTemplate last = template.Properties.LastOrDefault(); foreach (PropertyValueTemplate property in template.Properties) { output.Add($"{property.Name}: ") .Add(property.Value) .If(property != last).Add(",").EndIf() .BreakLine(); } output.UnIndent().Add("}"); }
public static PropertyValueTemplate FormatName(this PropertyValueTemplate propertyTemplate, IOptions options, bool force = false) { propertyTemplate.Name = Formatter.FormatProperty(propertyTemplate.Name, options, force); return(propertyTemplate); }