protected virtual void ApplyStyle(ResolvedControl control) { if (SetHtmlAttributes != null) { foreach (var attr in SetHtmlAttributes) { if (!control.HtmlAttributes.ContainsKey(attr.Key) || attr.Value.append) { ResolvedHtmlAttributeSetter setter = null; if (attr.Value.value is ResolvedBinding) { setter = new ResolvedHtmlAttributeBinding(attr.Key, (ResolvedBinding)attr.Value.value); } else { setter = new ResolvedHtmlAttributeValue(attr.Key, (string)attr.Value.value); } control.SetHtmlAttribute(setter); } } } if (SetProperties != null) { foreach (var prop in SetProperties) { if (!control.Properties.ContainsKey(prop.Key)) { control.Properties.Add(prop.Key, prop.Value); } } } }
/// <summary> /// Emits value or binding and returns /// </summary> protected ExpressionSyntax ProcessBindingOrValue(ResolvedHtmlAttributeSetter attribute, DataContextStack dataContext) { if (attribute is ResolvedHtmlAttributeValue) { return(emitter.EmitValue(((ResolvedHtmlAttributeValue)attribute).Value)); } else if (attribute is ResolvedHtmlAttributeBinding) { return(ProcessBinding(((ResolvedHtmlAttributeBinding)attribute).Binding, typeof(object))); } else { throw new NotSupportedException("Attribute type not supported."); } }