Example #1
0
        public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var record   = (PropertyTypeReferenceRecord)((BamlRecordNode)node).Record;
            var attr     = ctx.ResolveProperty(record.AttributeId);
            var type     = ctx.ResolveType(record.TypeId);
            var typeName = ctx.ToString(parent.Xaml, type);

            var elem = new BamlElement(node);

            var elemAttr = ctx.ResolveProperty(record.AttributeId);

            elem.Xaml = new XElement(elemAttr.ToXName(ctx, null));

            elem.Xaml.Element.AddAnnotation(elemAttr);
            parent.Xaml.Element.Add(elem.Xaml.Element);

            var typeElem = new XElement(ctx.GetXamlNsName("TypeExtension", parent.Xaml));

            typeElem.AddAnnotation(ctx.ResolveType(0xfd4d));             // Known type - TypeExtension
            typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));
            elem.Xaml.Element.Add(typeElem);

            elemAttr.DeclaringType.ResolveNamespace(elem.Xaml, ctx);
            elem.Xaml.Element.Name = elemAttr.ToXName(ctx, null);

            return(elem);
        }
        public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var record   = (PropertyTypeReferenceRecord)((BamlRecordNode)node).Record;
            var attr     = ctx.ResolveProperty(record.AttributeId);
            var type     = ctx.ResolveType(record.TypeId);
            var typeName = ctx.ToString(parent.Xaml, type);

            var elem = new BamlElement(node);

            var elemAttr = ctx.ResolveProperty(record.AttributeId);

            elem.Xaml = new XElement(elemAttr.ToXName(ctx, null));

            if (attr.ResolvedMember.FullNameIs("System.Windows.Style", "TargetType"))
            {
                parent.Xaml.Element.AddAnnotation(new TargetTypeAnnotation(type));
            }

            elem.Xaml.Element.AddAnnotation(elemAttr);
            parent.Xaml.Element.Add(elem.Xaml.Element);

            var typeElem = new XElement(ctx.GetKnownNamespace("TypeExtension", XamlContext.KnownNamespace_Xaml, parent.Xaml));

            typeElem.AddAnnotation(ctx.ResolveType(0xfd4d));             // Known type - TypeExtension
            typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));
            elem.Xaml.Element.Add(typeElem);

            elemAttr.DeclaringType.ResolveNamespace(elem.Xaml, ctx);
            elem.Xaml.Element.Name = elemAttr.ToXName(ctx, null);

            return(elem);
        }
Example #3
0
        public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var record = (ElementStartRecord)((BamlBlockNode)node).Header;
            var doc    = new BamlElement(node);

            var elemType = ctx.ResolveType(record.TypeId);

            doc.Xaml = new XElement(elemType.ToXName(ctx));

            doc.Xaml.Element.AddAnnotation(elemType);
            parent.Xaml.Element.Add(doc.Xaml.Element);

            HandlerMap.ProcessChildren(ctx, (BamlBlockNode)node, doc);
            if (node.Annotation is XamlResourceKey key && key.KeyNode.Record != node.Record)
            {
                var handler = (IDeferHandler)HandlerMap.LookupHandler(key.KeyNode.Record.Type);
                var keyElem = handler.TranslateDefer(ctx, key.KeyNode, doc);

                doc.Children.Add(keyElem);
                keyElem.Parent = doc;
            }

            elemType.ResolveNamespace(doc.Xaml, ctx);
            doc.Xaml.Element.Name = elemType.ToXName(ctx);

            return(doc);
        }
		public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) {
			var record = (ConstructorParameterTypeRecord)((BamlRecordNode)node).Record;

			var elem = new XElement(ctx.GetXamlNsName("TypeExtension", parent.Xaml));
			elem.AddAnnotation(ctx.ResolveType(0xfd4d)); // Known type - TypeExtension

			var bamlElem = new BamlElement(node);
			bamlElem.Xaml = elem;
			parent.Xaml.Element.Add(elem);

			var type = ctx.ResolveType(record.TypeId);
			var typeName = ctx.ToString(parent.Xaml, type);
			elem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));

			return bamlElem;
		}
Example #5
0
		public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) {
			var record = (ElementStartRecord)((BamlBlockNode)node).Header;
			var doc = new BamlElement(node);

			var elemType = ctx.ResolveType(record.TypeId);
			doc.Xaml = new XElement(elemType.ToXName(ctx));

			doc.Xaml.Element.AddAnnotation(elemType);
			parent.Xaml.Element.Add(doc.Xaml.Element);

			HandlerMap.ProcessChildren(ctx, (BamlBlockNode)node, doc);
			var key = node.Annotation as XamlResourceKey;
			if (key != null && key.KeyNode.Record != node.Record) {
				var handler = (IDeferHandler)HandlerMap.LookupHandler(key.KeyNode.Record.Type);
				var keyElem = handler.TranslateDefer(ctx, key.KeyNode, doc);

				doc.Children.Add(keyElem);
				keyElem.Parent = doc;
			}

			elemType.ResolveNamespace(doc.Xaml, ctx);
			doc.Xaml.Element.Name = elemType.ToXName(ctx);

			return doc;
		}
		public BamlElement TranslateDefer(XamlContext ctx, BamlNode node, BamlElement parent) {
			var record = (DefAttributeKeyTypeRecord)((BamlRecordNode)node).Record;
			var type = ctx.ResolveType(record.TypeId);
			var typeName = ctx.ToString(parent.Xaml, type);
			var key = (XamlResourceKey)node.Annotation;

			var bamlElem = new BamlElement(node);
			bamlElem.Xaml = new XElement(ctx.GetXamlNsName("Key", parent.Xaml));
			parent.Xaml.Element.Add(bamlElem.Xaml.Element);

			var typeElem = new XElement(ctx.GetXamlNsName("TypeExtension", parent.Xaml));
			typeElem.AddAnnotation(ctx.ResolveType(0xfd4d)); // Known type - TypeExtension
			typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));
			bamlElem.Xaml.Element.Add(typeElem);

			key.KeyElement = bamlElem;

			return bamlElem;
		}
Example #7
0
        public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var record = (ConstructorParameterTypeRecord)((BamlRecordNode)node).Record;

            var elem = new XElement(ctx.GetXamlNsName("TypeExtension", parent.Xaml));

            elem.AddAnnotation(ctx.ResolveType(0xfd4d));             // Known type - TypeExtension

            var bamlElem = new BamlElement(node);

            bamlElem.Xaml = elem;
            parent.Xaml.Element.Add(elem);

            var type     = ctx.ResolveType(record.TypeId);
            var typeName = ctx.ToString(parent.Xaml, type);

            elem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));

            return(bamlElem);
        }
        public BamlElement TranslateDefer(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var record   = (StaticResourceStartRecord)((BamlBlockNode)node).Record;
            var doc      = new BamlElement(node);
            var elemType = ctx.ResolveType(record.TypeId);

            doc.Xaml = new XElement(elemType.ToXName(ctx));
            doc.Xaml.Element.AddAnnotation(elemType);
            parent.Xaml.Element.Add(doc.Xaml.Element);
            HandlerMap.ProcessChildren(ctx, (BamlBlockNode)node, doc);
            return(doc);
        }
        public BamlElement TranslateDefer(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var record   = (DefAttributeKeyTypeRecord)((BamlRecordNode)node).Record;
            var type     = ctx.ResolveType(record.TypeId);
            var typeName = ctx.ToString(parent.Xaml, type);
            var key      = (XamlResourceKey)node.Annotation;

            var bamlElem = new BamlElement(node);

            bamlElem.Xaml = new XElement(ctx.GetKnownNamespace("Key", XamlContext.KnownNamespace_Xaml, parent.Xaml));
            parent.Xaml.Element.Add(bamlElem.Xaml.Element);

            var typeElem = new XElement(ctx.GetKnownNamespace("TypeExtension", XamlContext.KnownNamespace_Xaml, parent.Xaml));

            typeElem.AddAnnotation(ctx.ResolveType(0xfd4d));             // Known type - TypeExtension
            typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));
            bamlElem.Xaml.Element.Add(typeElem);

            key.KeyElement = bamlElem;

            return(bamlElem);
        }
		public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) {
			var record = (PropertyTypeReferenceRecord)((BamlRecordNode)node).Record;
			var attr = ctx.ResolveProperty(record.AttributeId);
			var type = ctx.ResolveType(record.TypeId);
			var typeName = ctx.ToString(parent.Xaml, type);

			var elem = new BamlElement(node);

			var elemAttr = ctx.ResolveProperty(record.AttributeId);
			elem.Xaml = new XElement(elemAttr.ToXName(ctx, null));

			elem.Xaml.Element.AddAnnotation(elemAttr);
			parent.Xaml.Element.Add(elem.Xaml.Element);

			var typeElem = new XElement(ctx.GetXamlNsName("TypeExtension", parent.Xaml));
			typeElem.AddAnnotation(ctx.ResolveType(0xfd4d)); // Known type - TypeExtension
			typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), typeName));
			elem.Xaml.Element.Add(typeElem);

			elemAttr.DeclaringType.ResolveNamespace(elem.Xaml, ctx);
			elem.Xaml.Element.Name = elemAttr.ToXName(ctx, null);

			return elem;
		}
Example #11
0
        public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var  record       = (PropertyWithExtensionRecord)((BamlRecordNode)node).Record;
            var  extTypeId    = ((short)record.Flags & 0xfff);
            bool valTypeExt   = ((short)record.Flags & 0x4000) == 0x4000;
            bool valStaticExt = ((short)record.Flags & 0x2000) == 0x2000;

            var elemType = parent.Xaml.Element.Annotation <XamlType>();
            var xamlProp = ctx.ResolveProperty(record.AttributeId);
            var extType  = ctx.ResolveType((ushort)-extTypeId);

            extType.ResolveNamespace(parent.Xaml, ctx);

            var ext = new XamlExtension(extType);

            if (valTypeExt || extTypeId == (short)KnownTypes.TypeExtension)
            {
                var value = ctx.ResolveType(record.ValueId);
                ext.Initializer = new object[] { ctx.ToString(parent.Xaml, value) };
            }
            else if (extTypeId == (short)KnownTypes.TemplateBindingExtension)
            {
                var value = ctx.ResolveProperty(record.ValueId);

                value.DeclaringType.ResolveNamespace(parent.Xaml, ctx);
                var xName = value.ToXName(ctx, parent.Xaml, false);

                ext.Initializer = new object[] { ctx.ToString(parent.Xaml, xName) };
            }
            else if (valStaticExt || extTypeId == (short)KnownTypes.StaticExtension)
            {
                string attrName;
                if (record.ValueId > 0x7fff)
                {
                    bool  isKey  = true;
                    short bamlId = (short)-record.ValueId;
                    if (bamlId > 232 && bamlId < 464)
                    {
                        bamlId -= 232;
                        isKey   = false;
                    }
                    else if (bamlId > 464 && bamlId < 467)
                    {
                        bamlId -= 231;
                    }
                    else if (bamlId > 467 && bamlId < 470)
                    {
                        bamlId -= 234;
                        isKey   = false;
                    }
                    var    res = ctx.Baml.KnownThings.Resources(bamlId);
                    string name;
                    if (isKey)
                    {
                        name = res.Item1 + "." + res.Item2;
                    }
                    else
                    {
                        name = res.Item1 + "." + res.Item3;
                    }
                    var xmlns = ctx.GetXmlNamespace("http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                    attrName = ctx.ToString(parent.Xaml, xmlns.GetName(name));
                }
                else
                {
                    var value = ctx.ResolveProperty(record.ValueId);

                    value.DeclaringType.ResolveNamespace(parent.Xaml, ctx);
                    var xName = value.ToXName(ctx, parent.Xaml);

                    attrName = ctx.ToString(parent.Xaml, xName);
                }
                ext.Initializer = new object[] { attrName };
            }
            else
            {
                ext.Initializer = new object[] { XamlUtils.Escape(ctx.ResolveString(record.ValueId)) };
            }

            var extValue = ext.ToString(ctx, parent.Xaml);
            var attr     = new XAttribute(xamlProp.ToXName(ctx, parent.Xaml, xamlProp.IsAttachedTo(elemType)), extValue);

            parent.Xaml.Element.Add(attr);

            return(null);
        }
        public BamlElement TranslateDefer(XamlContext ctx, BamlNode node, BamlElement parent)
        {
            var    record   = (OptimizedStaticResourceRecord)((BamlRecordNode)node).Record;
            var    bamlElem = new BamlElement(node);
            object key;

            if (record.IsType)
            {
                var value = ctx.ResolveType(record.ValueId);

                var typeElem = new XElement(ctx.GetKnownNamespace("TypeExtension", XamlContext.KnownNamespace_Xaml, parent.Xaml));
                typeElem.AddAnnotation(ctx.ResolveType(0xfd4d));                 // Known type - TypeExtension
                typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), ctx.ToString(parent.Xaml, value)));
                key = typeElem;
            }
            else if (record.IsStatic)
            {
                string attrName;
                if (record.ValueId > 0x7fff)
                {
                    bool  isKey  = true;
                    short bamlId = unchecked ((short)-record.ValueId);
                    if (bamlId > 232 && bamlId < 464)
                    {
                        bamlId -= 232;
                        isKey   = false;
                    }
                    else if (bamlId > 464 && bamlId < 467)
                    {
                        bamlId -= 231;
                    }
                    else if (bamlId > 467 && bamlId < 470)
                    {
                        bamlId -= 234;
                        isKey   = false;
                    }
                    var    res = ctx.Baml.KnownThings.Resources(bamlId);
                    string name;
                    if (isKey)
                    {
                        name = res.Item1 + "." + res.Item2;
                    }
                    else
                    {
                        name = res.Item1 + "." + res.Item3;
                    }
                    var xmlns = ctx.GetXmlNamespace("http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                    attrName = ctx.ToString(parent.Xaml, xmlns.GetName(name));
                }
                else
                {
                    var value = ctx.ResolveProperty(record.ValueId);

                    value.DeclaringType.ResolveNamespace(parent.Xaml, ctx);
                    var xName = value.ToXName(ctx, parent.Xaml);

                    attrName = ctx.ToString(parent.Xaml, xName);
                }

                var staticElem = new XElement(ctx.GetKnownNamespace("StaticExtension", XamlContext.KnownNamespace_Xaml, parent.Xaml));
                staticElem.AddAnnotation(ctx.ResolveType(0xfda6));                 // Known type - StaticExtension
                staticElem.Add(new XElement(ctx.GetPseudoName("Ctor"), attrName));
                key = staticElem;
            }
            else
            {
                key = ctx.ResolveString(record.ValueId);
            }

            var extType = ctx.ResolveType(0xfda5);
            var resElem = new XElement(extType.ToXName(ctx));

            resElem.AddAnnotation(extType);             // Known type - StaticResourceExtension
            bamlElem.Xaml = resElem;
            parent.Xaml.Element.Add(resElem);

            var attrElem = new XElement(ctx.GetPseudoName("Ctor"));

            attrElem.Add(key);
            resElem.Add(attrElem);

            return(bamlElem);
        }
		public BamlElement Translate(XamlContext ctx, BamlNode node, BamlElement parent) {
			var record = (PropertyWithExtensionRecord)((BamlRecordNode)node).Record;
			var extTypeId = ((short)record.Flags & 0xfff);
			bool valTypeExt = ((short)record.Flags & 0x4000) == 0x4000;
			bool valStaticExt = ((short)record.Flags & 0x2000) == 0x2000;

			var elemType = parent.Xaml.Element.Annotation<XamlType>();
			var xamlProp = ctx.ResolveProperty(record.AttributeId);
			var extType = ctx.ResolveType((ushort)-extTypeId);
			extType.ResolveNamespace(parent.Xaml, ctx);

			var ext = new XamlExtension(extType);
			if (valTypeExt || extTypeId == (short)KnownTypes.TypeExtension) {
				var value = ctx.ResolveType(record.ValueId);
				ext.Initializer = new object[] { ctx.ToString(parent.Xaml, value) };
			}
			else if (extTypeId == (short)KnownTypes.TemplateBindingExtension) {
				var value = ctx.ResolveProperty(record.ValueId);

				value.DeclaringType.ResolveNamespace(parent.Xaml, ctx);
				var xName = value.ToXName(ctx, parent.Xaml, false);

				ext.Initializer = new object[] { ctx.ToString(parent.Xaml, xName) };
			}
			else if (valStaticExt || extTypeId == (short)KnownTypes.StaticExtension) {
				string attrName;
				if (record.ValueId > 0x7fff) {
					bool isKey = true;
					short bamlId = (short)-record.ValueId;
					if (bamlId > 232 && bamlId < 464) {
						bamlId -= 232;
						isKey = false;
					}
					else if (bamlId > 464 && bamlId < 467) {
						bamlId -= 231;
					}
					else if (bamlId > 467 && bamlId < 470) {
						bamlId -= 234;
						isKey = false;
					}
					var res = ctx.Baml.KnownThings.Resources(bamlId);
					string name;
					if (isKey)
						name = res.Item1 + "." + res.Item2;
					else
						name = res.Item1 + "." + res.Item3;
					var xmlns = ctx.GetXmlNamespace("http://schemas.microsoft.com/winfx/2006/xaml/presentation");
					attrName = ctx.ToString(parent.Xaml, xmlns.GetName(name));
				}
				else {
					var value = ctx.ResolveProperty(record.ValueId);

					value.DeclaringType.ResolveNamespace(parent.Xaml, ctx);
					var xName = value.ToXName(ctx, parent.Xaml);

					attrName = ctx.ToString(parent.Xaml, xName);
				}
				ext.Initializer = new object[] { attrName };
			}
			else {
				ext.Initializer = new object[] { XamlUtils.Escape(ctx.ResolveString(record.ValueId)) };
			}

			var extValue = ext.ToString(ctx, parent.Xaml);
			var attr = new XAttribute(xamlProp.ToXName(ctx, parent.Xaml, xamlProp.IsAttachedTo(elemType)), extValue);
			parent.Xaml.Element.Add(attr);

			return null;
		}
        string Deserialize(XamlContext ctx, XElement elem, KnownTypes ser, byte[] value)
        {
            using (BinaryReader reader = new BinaryReader(new MemoryStream(value))) {
                switch (ser)
                {
                case KnownTypes.DependencyPropertyConverter: {
                    if (value.Length == 2)
                    {
                        var property = ctx.ResolveProperty(reader.ReadUInt16());
                        return(ctx.ToString(elem, property.ToXName(ctx, elem, false)));
                    }
                    else
                    {
                        var type     = ctx.ResolveType(reader.ReadUInt16());
                        var name     = reader.ReadString();
                        var typeName = ctx.ToString(elem, type);
                        return(typeName + "." + name);
                    }
                }

                case KnownTypes.EnumConverter: {
                    uint enumVal = reader.ReadUInt32();
                    // TODO: Convert to enum names
                    return(enumVal.ToString("D", CultureInfo.InvariantCulture));
                }

                case KnownTypes.BooleanConverter: {
                    Debug.Assert(value.Length == 1);
                    return((reader.ReadByte() == 1).ToString(CultureInfo.InvariantCulture));
                }

                case KnownTypes.XamlBrushSerializer: {
                    switch (reader.ReadByte())
                    {
                    case 1:                                     // KnownSolidColor
                        return(string.Format(CultureInfo.InvariantCulture, "#{0:X8}", reader.ReadUInt32()));

                    case 2:                                     // OtherColor
                        return(reader.ReadString());
                    }
                    break;
                }

                case KnownTypes.XamlPathDataSerializer:
                    return(XamlPathDeserializer.Deserialize(reader));

                case KnownTypes.XamlPoint3DCollectionSerializer:
                case KnownTypes.XamlVector3DCollectionSerializer: {
                    var sb    = new StringBuilder();
                    var count = reader.ReadUInt32();
                    for (uint i = 0; i < count; i++)
                    {
                        sb.AppendFormat(CultureInfo.InvariantCulture, "{0:R},{1:R},{2:R} ",
                                        reader.ReadXamlDouble(),
                                        reader.ReadXamlDouble(),
                                        reader.ReadXamlDouble());
                    }
                    return(sb.ToString().Trim());
                }

                case KnownTypes.XamlPointCollectionSerializer: {
                    var sb    = new StringBuilder();
                    var count = reader.ReadUInt32();
                    for (uint i = 0; i < count; i++)
                    {
                        sb.AppendFormat(CultureInfo.InvariantCulture, "{0:R},{1:R} ",
                                        reader.ReadXamlDouble(),
                                        reader.ReadXamlDouble());
                    }
                    return(sb.ToString().Trim());
                }

                case KnownTypes.XamlInt32CollectionSerializer: {
                    var sb    = new StringBuilder();
                    var type  = (IntegerCollectionType)reader.ReadByte();
                    var count = reader.ReadInt32();

                    switch (type)
                    {
                    case IntegerCollectionType.Consecutive: {
                        var start = reader.ReadInt32();
                        for (int i = 0; i < count; i++)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", start + i);
                        }
                    }
                    break;

                    case IntegerCollectionType.U1: {
                        for (int i = 0; i < count; i++)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", reader.ReadByte());
                        }
                    }
                    break;

                    case IntegerCollectionType.U2: {
                        for (int i = 0; i < count; i++)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", reader.ReadUInt16());
                        }
                    }
                    break;

                    case IntegerCollectionType.I4: {
                        for (int i = 0; i < count; i++)
                        {
                            sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", reader.ReadInt32());
                        }
                    }
                    break;

                    default:
                        throw new NotSupportedException(type.ToString());
                    }
                    return(sb.ToString().Trim());
                }
                }
            }
            throw new NotSupportedException(ser.ToString());
        }
Example #15
0
		string Deserialize(XamlContext ctx, XElement elem, KnownTypes ser, byte[] value) {
			using (BinaryReader reader = new BinaryReader(new MemoryStream(value))) {
				switch (ser) {
					case KnownTypes.DependencyPropertyConverter: {
						if (value.Length == 2) {
							var property = ctx.ResolveProperty(reader.ReadUInt16());
							return ctx.ToString(elem, property.ToXName(ctx, elem, false));
						}
						else {
							var type = ctx.ResolveType(reader.ReadUInt16());
							var name = reader.ReadString();
							var typeName = ctx.ToString(elem, type);
							return typeName + "." + name;
						}
					}

					case KnownTypes.EnumConverter: {
						uint enumVal = reader.ReadUInt32();
						// TODO: Convert to enum names
						return enumVal.ToString("D", CultureInfo.InvariantCulture);
					}

					case KnownTypes.BooleanConverter: {
						Debug.Assert(value.Length == 1);
						return (reader.ReadByte() == 1).ToString(CultureInfo.InvariantCulture);
					}

					case KnownTypes.XamlBrushSerializer: {
						switch (reader.ReadByte()) {
							case 1: // KnownSolidColor
								return string.Format(CultureInfo.InvariantCulture, "#{0:X8}", reader.ReadUInt32());
							case 2: // OtherColor
								return reader.ReadString();
						}
						break;
					}

					case KnownTypes.XamlPathDataSerializer:
						return XamlPathDeserializer.Deserialize(reader);

					case KnownTypes.XamlPoint3DCollectionSerializer:
					case KnownTypes.XamlVector3DCollectionSerializer: {
						var sb = new StringBuilder();
						var count = reader.ReadUInt32();
						for (uint i = 0; i < count; i++) {
							sb.AppendFormat(CultureInfo.InvariantCulture, "{0:R},{1:R},{2:R} ",
								reader.ReadXamlDouble(),
								reader.ReadXamlDouble(),
								reader.ReadXamlDouble());
						}
						return sb.ToString().Trim();
					}

					case KnownTypes.XamlPointCollectionSerializer: {
						var sb = new StringBuilder();
						var count = reader.ReadUInt32();
						for (uint i = 0; i < count; i++) {
							sb.AppendFormat(CultureInfo.InvariantCulture, "{0:R},{1:R} ",
								reader.ReadXamlDouble(),
								reader.ReadXamlDouble());
						}
						return sb.ToString().Trim();
					}

					case KnownTypes.XamlInt32CollectionSerializer: {
						var sb = new StringBuilder();
						var type = (IntegerCollectionType)reader.ReadByte();
						var count = reader.ReadInt32();

						switch (type) {
							case IntegerCollectionType.Consecutive: {
								var start = reader.ReadInt32();
								for (int i = 0; i < count; i++)
									sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", start + i);
							}
								break;
							case IntegerCollectionType.U1: {
								for (int i = 0; i < count; i++)
									sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", reader.ReadByte());
							}
								break;
							case IntegerCollectionType.U2: {
								for (int i = 0; i < count; i++)
									sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", reader.ReadUInt16());
							}
								break;
							case IntegerCollectionType.I4: {
								for (int i = 0; i < count; i++)
									sb.AppendFormat(CultureInfo.InvariantCulture, "{0:D}", reader.ReadInt32());
							}
								break;
							default:
								throw new NotSupportedException(type.ToString());
						}
						return sb.ToString().Trim();
					}
				}
			}
			throw new NotSupportedException(ser.ToString());
		}
		public BamlElement TranslateDefer(XamlContext ctx, BamlNode node, BamlElement parent) {
			var record = (OptimizedStaticResourceRecord)((BamlRecordNode)node).Record;
			var bamlElem = new BamlElement(node);
			object key;
			if (record.IsType) {
				var value = ctx.ResolveType(record.ValueId);

				var typeElem = new XElement(ctx.GetXamlNsName("TypeExtension", parent.Xaml));
				typeElem.AddAnnotation(ctx.ResolveType(0xfd4d)); // Known type - TypeExtension
				typeElem.Add(new XElement(ctx.GetPseudoName("Ctor"), ctx.ToString(parent.Xaml, value)));
				key = typeElem;
			}
			else if (record.IsStatic) {
				string attrName;
				if (record.ValueId > 0x7fff) {
					bool isKey = true;
					short bamlId = (short)-record.ValueId;
					if (bamlId > 232 && bamlId < 464) {
						bamlId -= 232;
						isKey = false;
					}
					else if (bamlId > 464 && bamlId < 467) {
						bamlId -= 231;
					}
					else if (bamlId > 467 && bamlId < 470) {
						bamlId -= 234;
						isKey = false;
					}
					var res = ctx.Baml.KnownThings.Resources(bamlId);
					string name;
					if (isKey)
						name = res.Item1 + "." + res.Item2;
					else
						name = res.Item1 + "." + res.Item3;
					var xmlns = ctx.GetXmlNamespace("http://schemas.microsoft.com/winfx/2006/xaml/presentation");
					attrName = ctx.ToString(parent.Xaml, xmlns.GetName(name));
				}
				else {
					var value = ctx.ResolveProperty(record.ValueId);

					value.DeclaringType.ResolveNamespace(parent.Xaml, ctx);
					var xName = value.ToXName(ctx, parent.Xaml);

					attrName = ctx.ToString(parent.Xaml, xName);
				}

				var staticElem = new XElement(ctx.GetXamlNsName("StaticExtension", parent.Xaml));
				staticElem.AddAnnotation(ctx.ResolveType(0xfda6)); // Known type - StaticExtension
				staticElem.Add(new XElement(ctx.GetPseudoName("Ctor"), attrName));
				key = staticElem;
			}
			else
				key = ctx.ResolveString(record.ValueId);

			var extType = ctx.ResolveType(0xfda5);
			var resElem = new XElement(extType.ToXName(ctx));
			resElem.AddAnnotation(extType); // Known type - StaticResourceExtension
			bamlElem.Xaml = resElem;
			parent.Xaml.Element.Add(resElem);

			var attrElem = new XElement(ctx.GetPseudoName("Ctor"));
			attrElem.Add(key);
			resElem.Add(attrElem);

			return bamlElem;
		}