public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) { var record = (StaticResourceIdRecord)((BamlRecordNode)node).Record; BamlNode found = node; XamlResourceKey key; do { key = XamlResourceKey.FindKeyInAncestors(found.Parent, out found); } while (key != null && record.StaticResourceId >= key.StaticResources.Count); if (key == null) { throw new Exception("Cannot find StaticResource @" + node.Record.Position); } var resNode = key.StaticResources[record.StaticResourceId]; var handler = (IDeferHandler)HandlerMap.LookupHandler(resNode.Type); var resElem = handler.TranslateDefer(ctx, resNode, parent); parent.Children.Add(resElem); resElem.Parent = parent; return(resElem); }
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) { var record = (StaticResourceStartRecord)((BamlBlockNode)node).Record; var key = XamlResourceKey.FindKeyInSiblings(node); key.StaticResources.Add(node); return(null); }
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) { var record = (PropertyWithStaticResourceIdRecord)((BamlRecordNode)node).Record; var doc = new BamlElement(node); var elemAttr = ctx.ResolveProperty(record.AttributeId); doc.Xaml = new XElement(elemAttr.ToXName(ctx, null)); doc.Xaml.Element.AddAnnotation(elemAttr); parent.Xaml.Element.Add(doc.Xaml.Element); BamlNode found = node; XamlResourceKey key; do { key = XamlResourceKey.FindKeyInAncestors(found.Parent, out found); } while (key != null && record.StaticResourceId >= key.StaticResources.Count); if (key == null) { throw new Exception("Cannot find StaticResource @" + node.Record.Position); } var resNode = key.StaticResources[record.StaticResourceId]; var handler = (IDeferHandler)HandlerMap.LookupHandler(resNode.Type); var resElem = handler.TranslateDefer(ctx, resNode, doc); doc.Children.Add(resElem); resElem.Parent = doc; elemAttr.DeclaringType.ResolveNamespace(doc.Xaml, ctx); doc.Xaml.Element.Name = elemAttr.ToXName(ctx, null); return(doc); }
public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) { XamlResourceKey.Create(node); return(null); }