protected override void OnWriteStartObject() { var tmp = object_states.Pop(); XamlType xamlType = tmp.Type; var nodeType = xamlType.IsMarkupExtension && !xamlType.ConstructionRequiresArguments ? XamlNodeType.Value : XamlNodeType.StartObject; WritePendingStartMember(nodeType); WritePendingValue(nodeType); string ns = xamlType.PreferredXamlNamespace; string prefix = GetPrefix(ns); // null prefix is not rejected... if (w.WriteState == WriteState.Attribute) { // MarkupExtension w.WriteString("{"); if (!String.IsNullOrEmpty(prefix)) { w.WriteString(prefix); w.WriteString(":"); } string name = ns == XamlLanguage.Xaml2006Namespace ? xamlType.InternalXmlName : xamlType.Name; w.WriteString(name); attribute_index = -1; // space between type and first member (if any). if (xamlType.IsMarkupExtension && xamlType.GetSortedConstructorArguments().GetEnumerator().MoveNext()) { w.WriteString(" "); } } else { WritePendingNamespaces(); w.WriteStartElement(prefix, xamlType.InternalXmlName, xamlType.PreferredXamlNamespace); var l = xamlType.TypeArguments; if (l != null) { w.WriteStartAttribute("x", "TypeArguments", XamlLanguage.Xaml2006Namespace); for (int i = 0; i < l.Count; i++) { if (i > 0) { w.WriteString(", "); } w.WriteString(new XamlTypeName(l [i]).ToString(prefix_lookup)); } w.WriteEndAttribute(); } } object_states.Push(tmp); }