YAXLib.YAXSerializer.RegisterNamespace C# (CSharp) Method

RegisterNamespace() private method

Registers the namespace to be added to the root element of the serialized document.
private RegisterNamespace ( XNamespace ns, string prefix ) : void
ns XNamespace The namespace to be added
prefix string The prefix for the namespace.
return void
        private void RegisterNamespace(XNamespace ns, string prefix)
        {
            if (!ns.IsEmpty())
                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);
            }
        }