Beispiel #1
0
        /// <summary>
        /// Registers the namespace to be added to the root element of the serialized document.
        /// </summary>
        /// <param name="ns">The namespace to be added</param>
        /// <param name="prefix">The prefix for the namespace.</param>
        private void RegisterNamespace(XNamespace ns, string prefix)
        {
            if (!ns.HasNamespace())
                return;

            if (m_namespaceToPrefix.ContainsKey(ns))
            {
                string existingPrefix = m_namespaceToPrefix[ns];
                // override the prefix only if already existing namespace has no prefix assigned
                if (String.IsNullOrEmpty(existingPrefix))
                    m_namespaceToPrefix[ns] = prefix;
            }
            else
            {
                m_namespaceToPrefix.Add(ns, prefix);
            }
        }
Beispiel #2
0
 internal void SetNamespaceToOverrideEmptyNamespace(XNamespace otherNamespace)
 {
     // if namespace info is not already set during construction,
     // then set it from the other YAXSerializer instance
     if (otherNamespace.HasNamespace() && !this.HasTypeNamespace)
     {
         this.TypeNamespace = otherNamespace;
     }
 }
Beispiel #3
0
 public static XName OverrideNsIfEmpty(this XName self, XNamespace ns)
 {
     if (self.Namespace.HasNamespace())
         return self;
     else if (ns.HasNamespace())
         return ns + self.LocalName;
     else
         return self;
 }