public Contact(string contactId, string fullName, string companyName, string city, string street1, string street2, string street3, string province, string postalCode, string countryCode, string email, Telephone voice, Telephone fax) { var postalAddress = new PostalAddress { City = city, Street1 = street1, Street2 = street2, Street3 = street3, StateProvince = province, PostalCode = postalCode, CountryCode = countryCode }; PostalInfo = new PostalInfo { m_name = fullName, m_org = companyName, m_type = PostalAddressType.LOC, m_address = postalAddress }; Email = email; Voice = voice; Fax = fax; Id = contactId; }
protected XmlElement AddressToXml(XmlDocument doc, string tagName, PostalInfo nameAddress) { XmlElement name_address_element = null; if (nameAddress != null) { name_address_element = doc.CreateElement(tagName, namespaceUri); if (nameAddress.m_type == null) { throw new EppException("missing the address type (postal info)"); } name_address_element.SetAttribute("type", nameAddress.m_type); if (nameAddress.m_name != null) { AddXmlElement(doc, name_address_element, "contact:name", nameAddress.m_name, namespaceUri); } if (nameAddress.m_org != null) { AddXmlElement(doc, name_address_element, "contact:org", nameAddress.m_org, namespaceUri); } if (nameAddress.m_address != null) { PostalAddress address = nameAddress.m_address; XmlElement address_element = doc.CreateElement("contact:addr", namespaceUri); // Because this method is used by contact create and update, // the lowest common denominator (update), says that all // members are optional. if (address.Street1 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street1, namespaceUri); } if (address.Street2 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street2, namespaceUri); } if (address.Street3 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street3, namespaceUri); } if (address.City != null) { AddXmlElement(doc, address_element, "contact:city", address.City, namespaceUri); } if (address.StateProvince != null) { AddXmlElement(doc, address_element, "contact:sp", address.StateProvince, namespaceUri); } if (address.PostalCode != null) { AddXmlElement(doc, address_element, "contact:pc", address.PostalCode, namespaceUri); } if (address.CountryCode != null) { AddXmlElement(doc, address_element, "contact:cc", address.CountryCode, namespaceUri); } if (address_element.ChildNodes.Count > 0) { name_address_element.AppendChild(address_element); } } } return(name_address_element); }
protected XmlElement AddressToXml(XmlDocument doc, String tagName, PostalInfo nameAddress) { XmlElement name_address_element = null; if (nameAddress != null) { name_address_element = doc.CreateElement(tagName, Namespace); if (nameAddress.m_type == null) { throw new EppException("missing the address type (postal info)"); } name_address_element.SetAttribute("type", nameAddress.m_type); if (nameAddress.m_name != null) { AddXmlElement(doc, name_address_element, "contact:name", nameAddress.m_name, ContactNamespace); } if (nameAddress.m_org != null) { AddXmlElement(doc, name_address_element, "contact:org", nameAddress.m_org, ContactNamespace); } if (nameAddress.m_address != null) { var address = nameAddress.m_address; var address_element = doc.CreateElement("contact:addr", ContactNamespace); // Because this method is used by contact create and update, // the lowest common denominator (update), says that all // members are optional. if (address.Street1 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street1, ContactNamespace); } if (address.Street2 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street2, ContactNamespace); } if (address.Street3 != null) { AddXmlElement(doc, address_element, "contact:street", address.Street3, ContactNamespace); } if (address.City != null) { AddXmlElement(doc, address_element, "contact:city", address.City, ContactNamespace); } if (address.StateProvince != null) { AddXmlElement(doc, address_element, "contact:sp", address.StateProvince, ContactNamespace); } if (address.PostalCode != null) { AddXmlElement(doc, address_element, "contact:pc", address.PostalCode, ContactNamespace); } if (address.CountryCode != null) { AddXmlElement(doc, address_element, "contact:cc", address.CountryCode, ContactNamespace); } if (address_element.ChildNodes.Count > 0) { name_address_element.AppendChild(address_element); } } } return name_address_element; }