using BaseDomain; namespace ChatMvc.Domain { public class Name : AValueObject { public Name(string fullName) { this.FullName = fullName; var names = fullName.Split(' '); if (names.Length >= 2) { this.FirstName = names[0]; this.LastName = names[names.Length-1]; } } public string FullName { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public override bool GetValidationExpression() { return this.IsValid = this.IsValidName(FullName); } public override string ToString() { return this.FullName; } protected override IEnumerable GetEqualityComponents() { yield return this.FullName; } private bool IsValidName(string fullName) { return fullName.Contains(' '); } public static implicit operator string(Name name) => name.FullName; public static explicit operator Name(string fullname) => new Name(fullname); } }