public References(Member source) { Initialize(source); ChildrenIds = new HashSet <Guid>(); PartnerId = new PropHistory <Guid?>().AddChange(null, Source.BirthDate); Partner.AddChange(null, Source.BirthDate); }
public Human(string birthFullName, DateTime birthDate) { Initialize(); SetBirthDate(birthDate); Status = new PropHistory <StatusOptions>().AddChange(StatusOptions.Unmarried, BirthDate); FullName.AddChange(birthFullName, BirthDate); Id = Guid.NewGuid(); }
protected virtual void Initialize() { FullName = new PropHistory <string>((value, _) => { if (string.IsNullOrEmpty(value)) { throw new HistoryViolationException("An empty full name."); } }); }
protected override void Initialize() { Status = new PropHistory <StatusOptions>((value, since) => { if (value == StatusOptions.Married && !HadPartner(since)) { throw new HistoryViolationException("Trying to get married with no partner."); } }); base.Initialize(); }
protected void Initialize(Member source) { Partner = new PropHistory <Member>(); Children = new Dictionary <Guid, Member>(); Source = source ?? throw new NullReferenceException("Trying to set null source."); }