public GarageEntity(string name) : base(name) { this.m_association = new OneToManyAssociation<GarageEntity, CarEntity>( root: this, added: newItem=> newItem.Garage = this, removed: oldItem => oldItem.Garage = null); }
private Consent IsOfCorrectType(OneToManyAssociation property, PropertyContext context) { var collectionNakedObject = (InternalCollectionAdapter)property.get(context.Target); NakedObjectSpecification elementSpec = collectionNakedObject.getElementSpecification(); if (context.ProposedNakedObject.getSpecification().isOfType(elementSpec)) { return(new Allow()); } return(new Veto(string.Format("Not a suitable type; must be a {0}", elementSpec.getFullName()))); }
public PersonEntity(string name) : base(name) { this.m_personCarAssociation = new OneToOneAssociation<PersonEntity, CarEntity>( this, getOnRef: car => car.Driver, setOnRef: (car, person) => car.Driver = person, unsetOnRef: (car, person) => car.Driver = ReferenceEquals(car.Driver, person) ? null : car.Driver); this.m_personAddressesAssociation = new OneToManyAssociation<PersonEntity, AddressEntity>( root: this, added: newItem=> newItem.AddPerson(this), removed: oldItem=> oldItem.RemovePerson(this)); }