Ejemplo n.º 1
0
        private ContactName ParseName()
        {
            var name = new ContactName
            {
                First  = string.Empty,
                Last   = string.Empty,
                Middle = string.Empty,
            };

            var parts = txtName.Text.Split(' ').ToList();

            if (parts.Count == 1)
            {
                name.First = parts[0];
            }
            else if (parts.Count == 2)
            {
                name.First = parts[0];
                name.Last  = parts[1];
            }
            else if (parts.Count > 2)
            {
                name.Last   = parts.PopLast();
                name.Middle = parts.PopLast();
                name.First  = string.Join(" ", parts);
            }

            return(name);
        }
Ejemplo n.º 2
0
 public static ContactName Duplicate(this ContactName name)
 {
     return(new ContactName
     {
         First = name.First.Duplicate(),
         Last = name.Last.Duplicate(),
         Middle = name.Middle.Duplicate(),
     });
 }
Ejemplo n.º 3
0
 public static string GetDisplay(this ContactName name)
 {
     string[] values = new[] { name.First, name.Middle, name.Last };
     return(string.Join(" ", values.Where(s => !string.IsNullOrWhiteSpace(s))));
 }