private static string CreatePath(PropertyInspectorItemBase attribute) { string template = GetControlTemplate("path.html"); template = template.Replace("{{ LABEL }}", attribute.Label); template = template.Replace("{{ REQUIRED }}", attribute.Required ? "required" : ""); return(template); }
private static string CreateTextArea(PropertyInspectorItemBase attribute, object?defaultValue) { string template = GetControlTemplate("textarea.html"); template = template.Replace("{{ LABEL }}", attribute.Label); template = template.Replace("{{ VALUE }}", defaultValue == null ? "" : (string)defaultValue); template = template.Replace("{{ REQUIRED }}", attribute.Required ? "required" : ""); return(template); }
private static string CreateSelect(PropertyInspectorItemBase attribute, PropertyInspectorSelectOptionAttribute[] options, object?defaultValue) { string template = GetControlTemplate("select.html"); template = template.Replace("{{ LABEL }}", attribute.Label); template = template.Replace("{{ REQUIRED }}", attribute.Required ? "required" : ""); var sb = new StringBuilder(); foreach (PropertyInspectorSelectOptionAttribute option in options) { sb.Append($"\t\t<option value='{option.Value}' {(option.Value == (string?) defaultValue ? "selected" : "")}>{option.Label}</option>"); if (!Equals(option, options.Last())) { sb.Append('\n'); } } template = template.Replace("{{ OPTIONS }}", sb.ToString()); return(template); }