private PropertyContext GetProperty(NakedObject nakedObject, string propertyName, bool onlyVisible = true) { if (string.IsNullOrEmpty(propertyName.Trim())) { throw new BadRequestNOSException(); } string nof2Id = propertyName.ToLower(); IEnumerable <NakedObjectField> fields = nakedObject.getSpecification().getFields(); if (onlyVisible) { fields = fields.Where(p => !p.isHidden() && p.isVisible(nakedObject).isAllowed()); } NakedObjectField property = fields.SingleOrDefault(p => p.getId() == nof2Id); if (property == null) { throw new PropertyResourceNotFoundNOSException(propertyName); } if (!property.isCollection()) { property.get(nakedObject); // get value so any errors happen inside error mapping code } return(new PropertyContext { Target = nakedObject, Property = property }); }
private Tuple <NakedObjectField, NakedObjectSpecification> GetPropertyTypeInternal(string typeName, string propertyName) { if (string.IsNullOrEmpty(typeName.Trim()) || string.IsNullOrEmpty(propertyName.Trim())) { throw new BadRequestNOSException(); } NakedObjectSpecification spec = [email protected]().loadSpecification(typeName); if (spec is NoMemberSpecification) { throw new TypeResourceNotFoundNOSException(typeName); } string nof2Id = propertyName.ToLower(); NakedObjectField property = spec.getFields().SingleOrDefault(p => p.getId() == nof2Id); if (property == null) { throw new PropertyResourceNotFoundNOSException(propertyName); } return(new Tuple <NakedObjectField, NakedObjectSpecification>(property, spec)); }
public AssociationFacade(NakedObjectField assoc, Naked target, IFrameworkFacade frameworkFacade) { this.assoc = assoc; this.target = target; FrameworkFacade = frameworkFacade; }