Ejemplo n.º 1
0
        private void AssignVCard(RdapEntity entity, JArray jArray)
        {
            if (jArray == null)
            {
                throw new JCardParseException("Invalid JCard received");
            }

            foreach (var child in jArray)
            {
                var grandChildren = child.Children <JToken>();
                if (grandChildren.Any())
                {
                    var type = grandChildren.First().Value <string>();
                    switch (type)
                    {
                    case "fn":
                        entity.FullName = GetStringContentFromVCard(grandChildren);
                        break;

                    case "kind":
                        entity.Kind = GetStringContentFromVCard(grandChildren);
                        break;

                    case "org":
                        entity.Organisation = GetStringContentFromVCard(grandChildren);
                        break;

                    case "tel":
                        var tel = GetStringContentFromVCard(grandChildren);
                        if (!string.IsNullOrWhiteSpace(tel))
                        {
                            entity.Telephones.Add(tel);
                        }
                        break;

                    case "email":
                        var email = GetStringContentFromVCard(grandChildren);
                        if (!string.IsNullOrWhiteSpace(email))
                        {
                            entity.Emails.Add(email);
                        }
                        break;

                    case "adr":
                        var adr = GetArrayContentFromVCard(grandChildren);
                        if (adr != null)
                        {
                            entity.Address = adr.ToArray();
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void Parse(IList <object> content, RdapEntity entity)
 {
     AssignVCard(entity, content.Skip(1).FirstOrDefault() as JArray);
 }