NServiceBus.XmlSerialization.SetDefaultNamespace C# (CSharp) Method

SetDefaultNamespace() static private method

static private SetDefaultNamespace ( System.Xml.Linq.XElement element, System.Xml.Linq.XNamespace newXmlns ) : void
element System.Xml.Linq.XElement
newXmlns System.Xml.Linq.XNamespace
return void
        static void SetDefaultNamespace(XElement element, XNamespace newXmlns)
        {
            var currentXmlns = element.GetDefaultNamespace();
            if (currentXmlns == newXmlns)
            {
                return;
            }

            foreach (var descendant in element.DescendantsAndSelf()
                .Where(e => e.Name.Namespace == currentXmlns))
            {
                descendant.Name = newXmlns.GetName(descendant.Name.LocalName);
            }
        }