public IXamlIlAstNode Transform(XamlIlAstTransformationContext context, IXamlIlAstNode node) { if (node is XamlIlAstXamlPropertyValueNode pn) { var assignments = XamlIlTransformHelpers.GeneratePropertyAssignments(context, pn.Property.GetClrProperty(), pn.Values); return(new XamlIlManipulationGroupNode(pn) { Children = assignments }); } else { return(node); } }
void SubTransform(XamlIlAstTransformationContext context, XamlIlAstObjectNode ni) { var valueIndexes = new List <int>(); for (var c = 0; c < ni.Children.Count; c++) { if (ni.Children[c] is IXamlIlAstValueNode) { valueIndexes.Add(c); } } if (valueIndexes.Count == 0) { return; } var type = ni.Type.GetClrType(); IXamlIlAstValueNode VNode(int ind) => (IXamlIlAstValueNode)ni.Children[ind]; var contentProperty = context.Configuration.FindContentProperty(type); if (contentProperty == null) { foreach (var ind in valueIndexes) { if (XamlIlTransformHelpers.TryCallAdd(context, null, type, VNode(ind), out var addCall)) { ni.Children[ind] = addCall; } else { throw new XamlIlLoadException( $"Type `{type.GetFqn()} does not have content property and suitable Add({VNode(ind).Type.GetClrType().GetFqn()}) not found", VNode(ind)); } } } else { XamlIlTransformHelpers.GeneratePropertyAssignments(context, contentProperty, valueIndexes.Count, num => VNode(valueIndexes[num]), (i, v) => ni.Children[valueIndexes[i]] = v); } }