internal string GetPrefixForNamespace(string @namespace) { if (@namespace == XamlConstants.PresentationNamespace) { return(null); } string prefix = _xmlDoc.DocumentElement.GetPrefixOfNamespace(@namespace); if (_xmlDoc.DocumentElement.NamespaceURI == @namespace && _xmlDoc.Prefix == String.Empty) { return(string.Empty); } if (String.IsNullOrEmpty(prefix)) { prefix = _typeFinder.GetPrefixForXmlNamespace(@namespace); string existingNamespaceForPrefix = null; if (!String.IsNullOrEmpty(prefix)) { existingNamespaceForPrefix = _xmlDoc.DocumentElement.GetNamespaceOfPrefix(prefix); } if (String.IsNullOrEmpty(prefix) || !String.IsNullOrEmpty(existingNamespaceForPrefix) && existingNamespaceForPrefix != @namespace) { do { prefix = "Controls" + namespacePrefixCounter++; } while (!String.IsNullOrEmpty(_xmlDoc.DocumentElement.GetNamespaceOfPrefix(prefix))); } string xmlnsPrefix = _xmlDoc.DocumentElement.GetPrefixOfNamespace(XamlConstants.XmlnsNamespace); System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(xmlnsPrefix)); _xmlDoc.DocumentElement.SetAttribute(xmlnsPrefix + ":" + prefix, @namespace); if (@namespace == XamlConstants.DesignTimeNamespace) { var ignorableProp = new XamlProperty(this._rootElement, new XamlDependencyPropertyInfo(MarkupCompatibilityProperties.IgnorableProperty, true)); ignorableProp.SetAttribute(prefix); } } return(prefix); }
internal override void AddNodeTo(XamlProperty property) { if (attribute != null) { property.ParentObject.XmlElement.Attributes.Append(attribute); } else if (textValue != null) { attribute = property.SetAttribute(textValue); textValue = null; } else if (cDataSection != null) { property.AddChildNodeToProperty(cDataSection); } else { property.AddChildNodeToProperty(textNode); } }
internal string GetPrefixForNamespace(string @namespace) { if (@namespace == XamlConstants.PresentationNamespace) { return null; } string prefix = _xmlDoc.DocumentElement.GetPrefixOfNamespace(@namespace); if (String.IsNullOrEmpty(prefix)) { prefix = _typeFinder.GetPrefixForXmlNamespace(@namespace); string existingNamespaceForPrefix = null; if (!String.IsNullOrEmpty(prefix)) { existingNamespaceForPrefix = _xmlDoc.DocumentElement.GetNamespaceOfPrefix(prefix); } if (String.IsNullOrEmpty(prefix) || !String.IsNullOrEmpty(existingNamespaceForPrefix) && existingNamespaceForPrefix != @namespace) { do { prefix = "Controls" + namespacePrefixCounter++; } while (!String.IsNullOrEmpty(_xmlDoc.DocumentElement.GetNamespaceOfPrefix(prefix))); } string xmlnsPrefix = _xmlDoc.DocumentElement.GetPrefixOfNamespace(XamlConstants.XmlnsNamespace); System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(xmlnsPrefix)); _xmlDoc.DocumentElement.SetAttribute(xmlnsPrefix + ":" + prefix, @namespace); if (@namespace == XamlConstants.DesignTimeNamespace) { var ignorableProp = new XamlProperty(this._rootElement,new XamlDependencyPropertyInfo(MarkupCompatibilityProperties.IgnorableProperty,true)); ignorableProp.SetAttribute(prefix); } } return prefix; }
internal override void AddNodeTo(XamlProperty property) { if (attribute != null) { property.ParentObject.XmlElement.Attributes.Append(attribute); } else if (textValue != null) { attribute = property.SetAttribute(textValue); textValue = null; } else if (cDataSection != null) { property.AddChildNodeToProperty(cDataSection); } else { property.AddChildNodeToProperty(textNode); } }