public static CollectionRepresentation Create(HttpRequestMessage req, PropertyContextSurface propertyContext, IList<OptionalProperty> optionals, RestControlFlags flags) { var collectionRepresentationStrategy = new CollectionRepresentationStrategy(req, propertyContext, flags); if (optionals.Count == 0) { return new CollectionRepresentation(collectionRepresentationStrategy); } return CreateWithOptionals<CollectionRepresentation>(new object[] {collectionRepresentationStrategy}, optionals); }
public AttachmentRepresentation(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(flags) { SetContentType(propertyContext); SetContentDisposition(propertyContext); SetStream(propertyContext); SetHeader(propertyContext.Target); }
public static InlinePropertyRepresentation Create(HttpRequestMessage req, PropertyContextSurface propertyContext, IList<OptionalProperty> optionals, RestControlFlags flags) { if (!RestUtils.IsBlobOrClob(propertyContext.Specification) && !RestUtils.IsAttachment(propertyContext.Specification)) { optionals.Add(new OptionalProperty(JsonPropertyNames.Value, GetPropertyValue(req, propertyContext.Property, propertyContext.Target, flags))); } RestUtils.AddChoices(req, propertyContext, optionals, flags); return CreateWithOptionals<InlinePropertyRepresentation>(new object[] {new PropertyRepresentationStrategy(req, propertyContext, flags)}, optionals); }
public UriMtHelper(HttpRequestMessage req, PropertyContextSurface propertyContext) : this(req) { assoc = propertyContext.Property; nakedObject = propertyContext.Target; spec = nakedObject.Specification; LinkObjectId oid = OidStrategyHolder.OidStrategy.GetOid(nakedObject); cachedId = oid.InstanceId; cachedType = oid.DomainType; }
public RestSnapshot(PropertyContextSurface propertyContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) : this(req, true) { logger.DebugFormat("RestSnapshot:propertyprompt"); populator = () => { representation = PromptRepresentation.Create(propertyContext, listContext, req, flags); SetHeaders(); }; }
protected CollectionValueRepresentation(PropertyContextSurface propertyContext, HttpRequestMessage req, RestControlFlags flags) : base(flags) { SetScalars(propertyContext); SetValue(propertyContext, req, flags); SelfRelType = new CollectionValueRelType(RelValues.Self, new UriMtHelper(req, propertyContext)); SetLinks(req, propertyContext, new ObjectRelType(RelValues.Up, new UriMtHelper(req, propertyContext.Target))); SetExtensions(); SetHeader(propertyContext.Target); }
protected PromptRepresentation(PropertyContextSurface propertyContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) : base(flags) { SetScalars(propertyContext.Property.Id); SetChoices(listContext, propertyContext, req); SelfRelType = new PromptRelType(RelValues.Self, new UriMtHelper(req, propertyContext)); SetLinks(req, listContext.ElementType, new ObjectRelType(RelValues.Up, new UriMtHelper(req, propertyContext.Target))); SetExtensions(); SetHeader(listContext.IsListOfServices); }
private void SetLinks(HttpRequestMessage req, PropertyContextSurface propertyContext, RelType parentRelType) { var tempLinks = new List<LinkRepresentation> { LinkRepresentation.Create(parentRelType, Flags), LinkRepresentation.Create(SelfRelType, Flags) }; if (Flags.FormalDomainModel) { tempLinks.Add(LinkRepresentation.Create(new DomainTypeRelType(RelValues.ReturnType, new UriMtHelper(req, propertyContext.Property)), Flags)); tempLinks.Add(LinkRepresentation.Create(new DomainTypeRelType(RelValues.ElementType, new UriMtHelper(req, propertyContext.Property.Specification)), Flags)); } Links = tempLinks.ToArray(); }
public static InlineMemberAbstractRepresentation Create(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) { IConsentSurface consent = propertyContext.Property.IsUsable(propertyContext.Target); var optionals = new List<OptionalProperty>(); if (consent.IsVetoed) { optionals.Add(new OptionalProperty(JsonPropertyNames.DisabledReason, consent.Reason)); } if (propertyContext.Property.IsCollection()) { return InlineCollectionRepresentation.Create(req, propertyContext, optionals, flags); } return InlinePropertyRepresentation.Create(req, propertyContext, optionals, flags); }
public static InlineCollectionRepresentation Create(HttpRequestMessage req, PropertyContextSurface propertyContext, IList<OptionalProperty> optionals, RestControlFlags flags) { if (propertyContext.Property.IsEager(propertyContext.Target) && !propertyContext.Target.IsTransient()) { IEnumerable<INakedObjectSurface> collectionItems = propertyContext.Property.GetNakedObject(propertyContext.Target).ToEnumerable(); IEnumerable<LinkRepresentation> items = collectionItems.Select(i => LinkRepresentation.Create(new ValueRelType(propertyContext.Property, new UriMtHelper(req, i)), flags, new OptionalProperty(JsonPropertyNames.Title, RestUtils.SafeGetTitle(i)))); optionals.Add(new OptionalProperty(JsonPropertyNames.Value, items.ToArray())); } var collectionRepresentationStrategy = new CollectionRepresentationStrategy(req, propertyContext, flags); if (optionals.Count == 0) { return new InlineCollectionRepresentation(collectionRepresentationStrategy); } return CreateWithOptionals<InlineCollectionRepresentation>(new object[] {collectionRepresentationStrategy}, optionals); }
public RestSnapshot(PropertyContextSurface propertyContext, HttpRequestMessage req, RestControlFlags flags, bool value = false) : this(propertyContext, req, false) { FilterBlobsAndClobs(propertyContext, flags); populator = () => { if (value) { representation = CollectionValueRepresentation.Create(propertyContext, req, flags); } else { representation = RequestingAttachment() ? AttachmentRepresentation.Create(req, propertyContext, flags) : MemberAbstractRepresentation.Create(req, propertyContext, flags); } SetHeaders(); }; }
public static PromptRepresentation Create(PropertyContextSurface propertyContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) { return new PromptRepresentation(propertyContext, listContext, req, flags); }
private static void FilterBlobsAndClobs(PropertyContextSurface propertyContext, RestControlFlags flags) { if (!flags.BlobsClobs) { if (RestUtils.IsBlobOrClob(propertyContext.Specification) && !RestUtils.IsAttachment(propertyContext.Specification)) { throw new PropertyResourceNotFoundNOSException(propertyContext.Id); } } }
public PropertyRepresentationStrategy(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(req, propertyContext, flags) {}
private void SetContentType(PropertyContextSurface context) { INakedObjectSurface no = context.Property.GetNakedObject(context.Target); string mtv = no != null ? no.GetAttachment().MimeType : AttachmentContext.DefaultMimeType; contentType = new MediaTypeHeaderValue(mtv); }
public CollectionRepresentationStrategy(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(req, propertyContext, flags) { collection = propertyContext.Property.GetNakedObject(propertyContext.Target); }
protected MemberRepresentationStrategy(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(flags) { this.req = req; this.propertyContext = propertyContext; objectUri = new UriMtHelper(req, propertyContext); self = new MemberRelType(RelValues.Self, new UriMtHelper(req, propertyContext)); }
private void SetContentDisposition(PropertyContextSurface context) { INakedObjectSurface no = context.Property.GetNakedObject(context.Target); string cd = no != null ? no.GetAttachment().ContentDisposition : AttachmentContext.DefaultContentDisposition; string fn = no != null ? no.GetAttachment().FileName : AttachmentContext.DefaultFileName; ContentDisposition = new ContentDispositionHeaderValue(cd) {FileName = fn}; }
public static CollectionValueRepresentation Create(PropertyContextSurface propertyContext, HttpRequestMessage req, RestControlFlags flags) { return new CollectionValueRepresentation(propertyContext, req, flags); }
private void SetChoices(ListContextSurface listContext, PropertyContextSurface propertyContext, HttpRequestMessage req) { Choices = listContext.List.Select(c => RestUtils.GetChoiceValue(req, c, propertyContext.Property, Flags)).ToArray(); }
private void SetScalars(PropertyContextSurface propertyContext) { Id = propertyContext.Property.Id; }
private void SetValue(PropertyContextSurface propertyContext, HttpRequestMessage req, RestControlFlags flags) { IEnumerable<INakedObjectSurface> collectionItems = propertyContext.Property.GetNakedObject(propertyContext.Target).ToEnumerable(); Value = collectionItems.Select(i => LinkRepresentation.Create(new ValueRelType(propertyContext.Property, new UriMtHelper(req, i)), flags, new OptionalProperty(JsonPropertyNames.Title, RestUtils.SafeGetTitle(i)))).ToArray(); }
private void SetStream(PropertyContextSurface context) { INakedObjectSurface no = context.Property.GetNakedObject(context.Target); AsStream = no != null ? no.GetAttachment().Content : new MemoryStream(); }
protected string GetAttachmentFileName(PropertyContextSurface context) { INakedObjectSurface no = context.Property.GetNakedObject(context.Target); return no != null ? no.GetAttachment().FileName : "UnknownFile"; }
public static void AddChoices(HttpRequestMessage req, PropertyContextSurface propertyContext, IList<OptionalProperty> optionals, RestControlFlags flags) { if (propertyContext.Property.IsChoicesEnabled && !propertyContext.Property.GetChoicesParameters().Any()) { INakedObjectSurface[] choices = propertyContext.Property.GetChoices(propertyContext.Target, null); object[] choicesArray = choices.Select(c => GetChoiceValue(req, c, propertyContext.Property, flags)).ToArray(); optionals.Add(new OptionalProperty(JsonPropertyNames.Choices, choicesArray)); } }
public static Representation Create(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) { return new AttachmentRepresentation(req, propertyContext, flags); }