Пример #1
0
        /// <summary>
        /// Extracts name server list from protocol "ns" XML element
        /// </summary>
        /// <param name="nameServersElement">Protocol "ns" XML element</param>
        /// <returns>Name server list</returns>
        public static NameServerList Extract(XElement nameServersElement)
        {
            List <NameServerInfo> nameServers;

            if (nameServersElement.Elements().Any(elem => elem.Name.LocalName == "hostObj"))
            {
                nameServers = nameServersElement
                              .Elements()
                              .Select(elem => new NameServerInfo(elem.Value))
                              .ToList();
            }
            else
            {
                nameServers = nameServersElement
                              .Elements()
                              .Select(elem =>
                {
                    var hostName  = elem.Element(SchemaHelper.DomainNs.GetName("hostName")).Value;
                    var hostAddrs = elem
                                    .Elements(SchemaHelper.DomainNs.GetName("hostAddr"))
                                    .Select(addrElem => IpAddress.Extract(addrElem));
                    return(new NameServerInfo(hostName, hostAddrs));
                })
                              .ToList();
            }

            return(new NameServerList(nameServers));
        }
Пример #2
0
        /// <summary>
        /// Extracts data from XML element
        /// </summary>
        /// <param name="objectElement">Object XML element</param>
        public void Extract(XElement objectElement)
        {
            this.Name   = GetValueByName(objectElement, "name");
            this.Roid   = objectElement.Element(SchemaHelper.HostNs.GetName("roid")).Value;
            this.Status = objectElement
                          .Elements()
                          .Where(elem => elem.Name.LocalName == "status")
                          .Select(status => StatusInfo.Extract(status))
                          .ToList();
            this.IPAddress = objectElement
                             .Elements()
                             .Where(elem => elem.Name.LocalName == "addr")
                             .Select(addr => IpAddress.Extract(addr))
                             .ToList();

            var clientIdElem = objectElement.Element(SchemaHelper.HostNs.GetName("clID"));

            this.ClientId = clientIdElem == null ? null : clientIdElem.Value;

            var createIdElem = objectElement.Element(SchemaHelper.HostNs.GetName("crID"));

            this.CreateId = createIdElem == null ? null : createIdElem.Value;

            var crdDateElem = objectElement.Element(SchemaHelper.HostNs.GetName("crDate"));

            this.CreateDate = crdDateElem == null ? (DateTime?)null : DateTime.Parse(crdDateElem.Value).ToUniversalTime();

            var updIdElem = objectElement.Element(SchemaHelper.HostNs.GetName("upID"));

            this.UpdateId = updIdElem == null ? null : updIdElem.Value;

            var updDateElem = objectElement.Element(SchemaHelper.HostNs.GetName("upDate"));

            this.UpdateDate = updDateElem == null ? (DateTime?)null : DateTime.Parse(updDateElem.Value).ToUniversalTime();

            var tranDateElem = objectElement.Element(SchemaHelper.HostNs.GetName("trDate"));

            this.TransferDate = tranDateElem == null ? (DateTime?)null : DateTime.Parse(tranDateElem.Value).ToUniversalTime();
        }