private void InitProperty(string property, string value, DomAttributeWithInitializers withInit) { PropertyInfo prop; DomAttribute attr = withInit.Attribute; if (property == null) { var valueProp = HxlAttributeFragmentDefinition.ForComponent(attr).ValueProperty; if (valueProp == null) { valueProp = Utility.ReflectGetProperty(attr.GetType(), "Value"); } // TODO Might not have a value property (should implement an expression around the Value property) prop = valueProp; } else { // TODO Obtain line numbers prop = Utility.ReflectGetProperty(attr.GetType(), property); if (prop == null) { throw HxlFailure.ServerAttributePropertyNotFound(attr.GetType(), property, -1, -1); } } if (!HxlAttributeConverter.IsExpr(value)) { if (property == null) { withInit.Attribute.Value = value; } withInit.Initializers.Add(prop.Name, value); return; } var buffer = new ExpressionBuffer(); RewriteExpressionSyntax.MatchVariablesAndEmit(buffer, value); // TODO Could allow multiple exprs if (buffer.Parts.Count == 1) { } else { throw new NotImplementedException("ex"); } attr.AddAnnotation(new ExpressionInitializers(prop, buffer.Parts[0])); }
private DomAttribute CreateDomAttribute(DomAttribute m) { DomAttribute attr = Document.CreateAttribute(m.Name, m.Value); if (attr == null) { throw new NotImplementedException(); } AddImplicitType(attr.GetType()); _current.Attributes.Add(attr); return(attr); }