public RestSnapshot(ObjectContextSurface objectContext, HttpRequestMessage req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(objectContext, req, true) { populator = () => { this.httpStatusCode = httpStatusCode; representation = ObjectRepresentation.Create(objectContext, req, flags); SetHeaders(); }; }
private void SetLinks(HttpRequestMessage req, ObjectContextSurface objectContext) { var tempLinks = new List<LinkRepresentation>(); if (Flags.FormalDomainModel) { tempLinks.Add(LinkRepresentation.Create(new DomainTypeRelType(RelValues.ReturnType, new UriMtHelper(req, objectContext.Specification)), Flags)); } Links = tempLinks.ToArray(); }
protected ListRepresentation(ObjectContextSurface objectContext, HttpRequestMessage req, RestControlFlags flags, ActionContextSurface actionContext) : base(flags) { INakedObjectSurface list; if (flags.PageSize > 0 && objectContext.Target.Count() > flags.PageSize) { warnings.Add(string.Format("Result contains more than {0} objects only returning the first {0}", flags.PageSize)); list = objectContext.Target.Page(1, flags.PageSize); } else { list = objectContext.Target; } Value = list.ToEnumerable().Select(no => CreateObjectLink(req, no)).ToArray(); SetLinks(req, actionContext); SetExtensions(); SetHeader(false); }
public static ScalarRepresentation Create(ObjectContextSurface objectContext, HttpRequestMessage req, RestControlFlags flags) { return new ScalarRepresentation(req, objectContext, flags); }
private void SetScalars(ObjectContextSurface objectContext) { Value = RestUtils.ObjectToPredefinedType(objectContext.Target.Object); }
protected ScalarRepresentation(HttpRequestMessage req, ObjectContextSurface objectContext, RestControlFlags flags) : base(flags) { SetScalars(objectContext); SetLinks(req, objectContext); SetExtensions(); }