public MediaTypeHeaderValue GetAttachmentMediaType() { INakedObjectSurface no = assoc.GetNakedObject(nakedObject); string mtv = no != null?no.GetAttachment().MimeType : ""; return(new MediaTypeHeaderValue(string.IsNullOrWhiteSpace(mtv) ? "image/bmp" : mtv)); }
protected static object GetPropertyValue(HttpRequestMessage req, INakedObjectAssociationSurface property, INakedObjectSurface target, RestControlFlags flags, bool valueOnly = false) { INakedObjectSurface valueNakedObject = property.GetNakedObject(target); string title = RestUtils.SafeGetTitle(property, valueNakedObject); if (valueNakedObject == null) { return(null); } if (property.Specification.IsParseable() || property.Specification.IsCollection()) { return(RestUtils.ObjectToPredefinedType(valueNakedObject.Object)); } if (valueOnly) { return(RefValueRepresentation.Create(new ValueRelType(property, new UriMtHelper(req, valueNakedObject)), flags)); } var helper = new UriMtHelper(req, property.IsInline() ? target : valueNakedObject); var optionals = new List <OptionalProperty> { new OptionalProperty(JsonPropertyNames.Title, title) }; if (property.IsEager(target)) { optionals.Add(new OptionalProperty(JsonPropertyNames.Value, ObjectRepresentation.Create(valueNakedObject, req, flags))); } return(LinkRepresentation.Create(new ValueRelType(property, helper), flags, optionals.ToArray())); }