示例#1
0
        private void When(CarItemAddedEvent @event) =>
        With(this, state =>
        {
            var newItem = CarItem.Create(new CarItemId(@event.CarItemId), @event.CarId, @event.Desciption);

            state._carItems = state._carItems ?? new List <CarItemState>();

            state._carItems.Add(newItem.State);
        });
示例#2
0
        public void RestoreSnapshot(object state)
        {
            var snapshot = (CarStateSnapshot)state;

            this.Id        = new CarId(snapshot.Id);
            this._name     = snapshot.Name;
            this.Year      = snapshot.Year;
            this._carItems = this._carItems ?? new List <CarItemState>();
            this._carItems = snapshot.CarItems?.Select(c => CarItem.Create(c.Id, new CarId(c.CarId), c.Desciption).State).ToList() ?? this._carItems;
        }