NServiceBus.XmlDeserialization.CacheDefaultNameSpaceMessageBaseTypesAndPrefixes C# (CSharp) Method

CacheDefaultNameSpaceMessageBaseTypesAndPrefixes() public method

public CacheDefaultNameSpaceMessageBaseTypesAndPrefixes ( XmlDocument doc ) : void
doc System.Xml.XmlDocument
return void
        void CacheDefaultNameSpaceMessageBaseTypesAndPrefixes(XmlDocument doc)
        {
            foreach (XmlAttribute attr in doc.DocumentElement.Attributes)
            {
                if (attr.Name == "xmlns")
                {
                    defaultNameSpace = attr.Value.Substring(attr.Value.LastIndexOf("/") + 1);
                }
                else
                {
                    if (attr.Name.Contains("xmlns:"))
                    {
                        var colonIndex = attr.Name.LastIndexOf(":");
                        var prefix = attr.Name.Substring(colonIndex + 1);

                        if (prefix.Contains(BASETYPE))
                        {
                            var baseType = mapper.GetMappedTypeFor(attr.Value);
                            if (baseType != null)
                            {
                                messageBaseTypes.Add(baseType);
                            }
                        }
                        else
                        {
                            prefixesToNamespaces[prefix] = attr.Value;
                        }
                    }
                }
            }
        }