BExIS.Xml.Helpers.Mapping.XmlMapperManager.addAttributesToXmlNode C# (CSharp) Method

addAttributesToXmlNode() private method

private addAttributesToXmlNode ( XmlDocument doc, XmlNode node, List attributes ) : XmlNode
doc System.Xml.XmlDocument
node System.Xml.XmlNode
attributes List
return System.Xml.XmlNode
        private XmlNode addAttributesToXmlNode(XmlDocument doc, XmlNode node, List<XmlSchemaAttribute> attributes)
        {
            foreach (XmlSchemaAttribute attribute in attributes)
            {
                string attrName = "";
                attrName = String.IsNullOrEmpty(attribute.Name) ? "" : attribute.Name;

                if (String.IsNullOrEmpty(attribute.Name))
                {
                    attrName = String.IsNullOrEmpty(attribute.QualifiedName.Name) ? attrName : attribute.QualifiedName.Name;
                }

                if (!String.IsNullOrEmpty(attrName))//&& attribute.DefaultValue!=null)
                {
                    XmlAttribute attr = doc.CreateAttribute(attrName);
                    if (attrName.Equals("language"))
                    {
                        attr.InnerXml = "en";
                    }
                    else
                    {
                        if (attribute.DefaultValue != null)
                        {
                            attr.InnerXml = attribute.DefaultValue;
                        }
                        else
                        {
                            XmlSchemaAttribute tmp =
                                xmlSchemaManager.Attributes.Where(a => a.Name.Equals(attrName)).FirstOrDefault();

                            if (tmp != null)
                                attr.InnerXml = tmp.DefaultValue;

                        }

                    }

                    node.Attributes.Append(attr);

                }
            }

            return node;
        }