示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#4
0
 public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent)
 {
     XamlResourceKey.Create(node);
     return(null);
 }