public static MapRepresentation Create(HttpRequestMessage req, ContextSurface context, Format format, RestControlFlags flags, MediaTypeHeaderValue mt) { var objectContextSurface = context as ObjectContextSurface; var actionResultContextSurface = context as ActionResultContextSurface; MapRepresentation mapRepresentation; if (objectContextSurface != null) { List<OptionalProperty> optionalProperties = objectContextSurface.VisibleProperties.Where(p => p.Reason != null || p.ProposedValue != null).Select(c => new OptionalProperty(c.Id, GetMap(req, c, flags))).ToList(); if (!string.IsNullOrEmpty(objectContextSurface.Reason)) { optionalProperties.Add(new OptionalProperty(JsonPropertyNames.XRoInvalidReason, objectContextSurface.Reason)); } mapRepresentation = Create(optionalProperties.ToArray()); } else if (actionResultContextSurface != null) { List<OptionalProperty> optionalProperties = actionResultContextSurface.ActionContext.VisibleParameters.Select(c => new OptionalProperty(c.Id, GetMap(req, c, flags))).ToList(); if (!string.IsNullOrEmpty(actionResultContextSurface.Reason)) { optionalProperties.Add(new OptionalProperty(JsonPropertyNames.XRoInvalidReason, actionResultContextSurface.Reason)); } mapRepresentation = Create(optionalProperties.ToArray()); } else { mapRepresentation = GetMap(req, context, flags); } mapRepresentation.SetContentType(mt); return mapRepresentation; }
public static MapRepresentation Create(HttpRequestMessage req, IList<ContextSurface> contexts, Format format, RestControlFlags flags, MediaTypeHeaderValue mt) { OptionalProperty[] memberValues = contexts.Select(c => new OptionalProperty(c.Id, GetMap(req, c, flags))).ToArray(); INakedObjectSurface target = contexts.First().Target; MapRepresentation mapRepresentation; if (format == Format.Full) { var tempProperties = new List<OptionalProperty>(); if (flags.SimpleDomainModel) { var dt = new OptionalProperty(JsonPropertyNames.DomainType, target.Specification.DomainTypeName()); tempProperties.Add(dt); } if (flags.FormalDomainModel) { var links = new OptionalProperty(JsonPropertyNames.Links, new[] { Create(new OptionalProperty(JsonPropertyNames.Rel, RelValues.DescribedBy), new OptionalProperty(JsonPropertyNames.Href, new UriMtHelper(req, target.Specification).GetDomainTypeUri())) }); tempProperties.Add(links); } var members = new OptionalProperty(JsonPropertyNames.Members, Create(memberValues)); tempProperties.Add(members); mapRepresentation = Create(tempProperties.ToArray()); } else { mapRepresentation = Create(memberValues); } mapRepresentation.SetContentType(mt); return mapRepresentation; }
protected ParameterTypeRepresentation(HttpRequestMessage req, ParameterTypeContextSurface parameterTypeContext, RestControlFlags flags) : base(flags) { SetScalars(parameterTypeContext); SelfRelType = new ParamTypeRelType(RelValues.Self, new UriMtHelper(req, parameterTypeContext)); SetLinks(req, parameterTypeContext); SetExtensions(); SetHeader(); }
private UserRepresentation(HttpRequestMessage req, IPrincipal user, RestControlFlags flags) : base(flags) { SelfRelType = new UserRelType(RelValues.Self, new UriMtHelper(req)); SetLinks(new HomePageRelType(RelValues.Up, new UriMtHelper(req))); SetScalars(user); SetExtensions(); SetHeader(); }
protected MemberTypeRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyTypeContextFacade propertyContext, RestControlFlags flags) : base(oidStrategy, flags) { SetScalars(propertyContext); SelfRelType = new TypeMemberRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, propertyContext)); SetExtensions(); SetHeader(); }
public ActionRepresentationStrategy(IOidStrategy oidStrategy, HttpRequestMessage req, ActionContextFacade actionContext, RestControlFlags flags) : base(oidStrategy, flags) { this.req = req; this.actionContext = actionContext; self = new MemberRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, actionContext)); parameterList = GetParameterList(); }
public RestSnapshot(IOidStrategy oidStrategy, ActionResultContextFacade actionResultContext, HttpRequestMessage req, RestControlFlags flags) : this(oidStrategy,actionResultContext, req, true) { populator = () => { representation = ActionResultRepresentation.Create(oidStrategy ,req, actionResultContext, flags); SetHeaders(); }; }
public AttachmentRepresentation(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(flags) { SetContentType(propertyContext); SetContentDisposition(propertyContext); SetStream(propertyContext); SetHeader(propertyContext.Target); }
protected ActionResultRepresentation(HttpRequestMessage req, ActionResultContextSurface actionResult, RestControlFlags flags) : base(flags) { SelfRelType = new ActionResultRelType(RelValues.Self, new UriMtHelper(req, actionResult.ActionContext)); SetResultType(actionResult); SetLinks(req, actionResult); SetExtensions(); SetHeader(); }
public static InlinePropertyRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, IList<OptionalProperty> optionals, RestControlFlags flags) { if (!RestUtils.IsBlobOrClob(propertyContext.Specification) && !RestUtils.IsAttachment(propertyContext.Specification)) { optionals.Add(new OptionalProperty(JsonPropertyNames.Value, GetPropertyValue(oidStrategy ,req, propertyContext.Property, propertyContext.Target, flags))); } RestUtils.AddChoices(oidStrategy , req, propertyContext, optionals, flags); return CreateWithOptionals<InlinePropertyRepresentation>(new object[] {oidStrategy, new PropertyRepresentationStrategy(oidStrategy ,req, propertyContext, flags)}, optionals); }
protected MemberRepresentationStrategy(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, RestControlFlags flags) : base(oidStrategy ,flags) { this.req = req; this.propertyContext = propertyContext; objectUri = new UriMtHelper(oidStrategy ,req, propertyContext); self = new MemberRelType(RelValues.Self, new UriMtHelper(oidStrategy , req, propertyContext)); }
protected TypeActionInvokeRepresentation(HttpRequestMessage req, TypeActionInvokeContext context, RestControlFlags flags) : base(flags) { SelfRelType = new TypeActionInvokeRelType(RelValues.Self, new UriMtHelper(req, context)); SetScalars(context); SetLinks(req, context); SetExtensions(); SetHeader(); }
protected ParameterRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, IObjectFacade objectFacade, IActionParameterFacade parameter, RestControlFlags flags) : base(oidStrategy, flags) { SetName(parameter); SetExtensions(req, objectFacade, parameter, flags); SetLinks(req, objectFacade, parameter); SetHeader(objectFacade); }
protected HomePageRepresentation(HttpRequestMessage req, RestControlFlags flags) : base(flags) { Log.DebugFormat("HomePageRepresentation"); SelfRelType = new HomePageRelType(RelValues.Self, new UriMtHelper(req)); SetLinks(req); SetExtensions(); SetHeader(); }
public static InlineCollectionRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, IList<OptionalProperty> optionals, RestControlFlags flags) { var collectionRepresentationStrategy = new CollectionRepresentationStrategy(oidStrategy, req, propertyContext, flags); if (optionals.Count == 0) { return new InlineCollectionRepresentation(oidStrategy, collectionRepresentationStrategy); } return CreateWithOptionals<InlineCollectionRepresentation>(new object[] {oidStrategy, collectionRepresentationStrategy}, optionals); }
public RestSnapshot(ActionResultContextSurface actionResultContext, HttpRequestMessage req, RestControlFlags flags) : this(actionResultContext, req, true) { populator = () => { representation = ActionResultRepresentation.Create(req, actionResultContext, flags); SetHeaders(); }; }
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 RestSnapshot(ParameterContextSurface parmContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) : this(req, true) { logger.DebugFormat("RestSnapshot:parameterprompt"); populator = () => { representation = PromptRepresentation.Create(parmContext, listContext, req, flags); SetHeaders(); }; }
private ListRepresentation(IOidStrategy oidStrategy, ITypeFacade[] specs, HttpRequestMessage req, RestControlFlags flags) : base(oidStrategy, flags) { Value = specs.Select(s => CreateDomainLink(oidStrategy, req, s)).ToArray(); SelfRelType = new TypesRelType(RelValues.Self, new UriMtHelper(oidStrategy, req)); SetLinks(req); SetExtensions(); SetHeader(true); }
private VersionRepresentation(HttpRequestMessage req, IDictionary<string, string> capabilitiesMap, RestControlFlags flags) : base(flags) { SelfRelType = new VersionRelType(RelValues.Self, new UriMtHelper(req)); SetScalars(); SetLinks(new HomePageRelType(RelValues.Up, new UriMtHelper(req))); SetOptionalCapabilities(capabilitiesMap); SetExtensions(); SetHeader(); }
protected ListRepresentation(IOidStrategy oidStrategy, IMenuFacade[] menus, HttpRequestMessage req, RestControlFlags flags) : base(oidStrategy, flags) { Value = menus.Select(c => CreateMenuLink(oidStrategy, req, c)).ToArray(); SelfRelType = new ListRelType(RelValues.Self, SegmentValues.Services, new UriMtHelper(oidStrategy, req)); SetLinks(req); SetExtensions(); SetHeader(true); }
public RestSnapshot(ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) : this(req, true) { logger.DebugFormat("RestSnapshot:ServicesList"); populator = () => { representation = ListRepresentation.Create(listContext, req, flags); SetHeaders(); }; }
protected ActionTypeRepresentation(HttpRequestMessage req, ActionTypeContextSurface actionTypeContext, RestControlFlags flags) : base(flags) { SelfRelType = new TypeMemberRelType(RelValues.Self, new UriMtHelper(req, actionTypeContext)); SetScalars(actionTypeContext); SetLinks(req, actionTypeContext); SetParameters(req, actionTypeContext); SetExtensions(); SetHeader(); }
private ListRepresentation(INakedObjectSpecificationSurface[] specs, HttpRequestMessage req, RestControlFlags flags) : base(flags) { Value = specs.Select(s => CreateDomainLink(req, s)).ToArray(); SelfRelType = new TypesRelType(RelValues.Self, new UriMtHelper(req)); SetLinks(req); SetExtensions(); SetHeader(true); }
protected ActionResultRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, ActionResultContextFacade actionResult, RestControlFlags flags) : base(oidStrategy, flags) { SelfRelType = new ActionResultRelType(RelValues.Self, new UriMtHelper(OidStrategy, req, actionResult.ActionContext)); SetResultType(actionResult); SetLinks(req, actionResult); SetExtensions(); SetHeader(); }
protected ListRepresentation(ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) : base(flags) { Value = listContext.List.Select(c => CreateObjectLink(req, c)).ToArray(); SelfRelType = new ListRelType(RelValues.Self, SegmentValues.Services, new UriMtHelper(req, listContext.ElementType)); SetLinks(req); SetExtensions(); SetHeader(listContext.IsListOfServices); }
public RestSnapshot(IOidStrategy oidStrategy, PropertyContextFacade propertyContext, ListContextFacade listContext, HttpRequestMessage req, RestControlFlags flags) : this(oidStrategy,req, true) { logger.DebugFormat("RestSnapshot:propertyprompt"); populator = () => { representation = PromptRepresentation.Create(oidStrategy ,propertyContext, listContext, req, flags); SetHeaders(); }; }
public RestSnapshot(IOidStrategy oidStrategy, ObjectContextFacade objectContext, HttpRequestMessage req, RestControlFlags flags, HttpStatusCode httpStatusCode = HttpStatusCode.OK) : this(oidStrategy,objectContext, req, true) { populator = () => { this.httpStatusCode = httpStatusCode; representation = ObjectRepresentation.Create(oidStrategy, objectContext, req, flags); SetHeaders(); }; }
protected FilterFromInvokeRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, FilterFromInvokeContext context, RestControlFlags flags) : base(oidStrategy, flags) { SelfRelType = new TypeActionFilterInvokeRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, context)); SetScalar(context); SetValue(req, context); SetLinks(req, context); SetExtensions(); SetHeader(); }
protected ObjectRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, ObjectContextFacade objectContext, RestControlFlags flags) : base(oidStrategy, flags) { var objectUri = new UriMtHelper(oidStrategy ,req, objectContext.Target); SetScalars(objectContext); SelfRelType = objectContext.Specification.IsService ? new ServiceRelType(RelValues.Self, objectUri) : new ObjectRelType(RelValues.Self, objectUri); SetLinksAndMembers(req, objectContext); SetExtensions(objectContext.Target); SetHeader(objectContext); }
public abstract MediaTypeHeaderValue GetMediaType(RestControlFlags flags);
public static void AddChoices(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, IList <OptionalProperty> optionals, RestControlFlags flags) { if (propertyContext.Property.IsChoicesEnabled != Choices.NotEnabled && !propertyContext.Property.GetChoicesParameters().Any()) { IObjectFacade[] choices = propertyContext.Property.GetChoices(propertyContext.Target, null); object[] choicesArray = choices.Select(c => GetChoiceValue(oidStrategy, req, c, propertyContext.Property, flags)).ToArray(); optionals.Add(new OptionalProperty(JsonPropertyNames.Choices, choicesArray)); } }
public static object GetChoiceValue(IOidStrategy oidStrategy, IObjectFacade item, ChoiceRelType relType, RestControlFlags flags) { string title = SafeGetTitle(item); object value = ObjectToPredefinedType(item.GetDomainObject()); return(item.Specification.IsParseable ? value : LinkRepresentation.Create(oidStrategy, relType, flags, new OptionalProperty(JsonPropertyNames.Title, title))); }
public static object GetChoiceValue(IOidStrategy oidStrategy, HttpRequestMessage req, IObjectFacade item, IActionParameterFacade parameter, RestControlFlags flags) { return(GetChoiceValue(oidStrategy, item, new ChoiceRelType(parameter, new UriMtHelper(oidStrategy, req, item)), flags)); }
public static OptionalProperty CreateArgumentProperty(IOidStrategy oidStrategy, HttpRequestMessage req, Tuple <string, ITypeFacade> pnt, RestControlFlags flags) { var tempLinks = new List <LinkRepresentation>(); if (flags.FormalDomainModel) { tempLinks.Add(LinkRepresentation.Create(oidStrategy, new DomainTypeRelType(RelValues.DescribedBy, new UriMtHelper(oidStrategy, req, pnt.Item2)), flags)); } return(new OptionalProperty(pnt.Item1, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object)), new OptionalProperty(JsonPropertyNames.Links, tempLinks.ToArray())))); }
public override MediaTypeHeaderValue GetMediaType(RestControlFlags flags) { return(helper.GetIconMediaType()); }
public override MediaTypeHeaderValue GetMediaType(RestControlFlags flags) { return(UriMtHelper.GetJsonMediaType(RepresentationTypes.Version)); }
public void AddObjectCollectionRepresentationParameter(MediaTypeHeaderValue mediaType, RestControlFlags flags) { if (assoc != null && assoc.IsCollection()) { string parameterValue = GetParameterValue(flags, assoc.ElementSpecification); if (parameterValue != null) { mediaType.Parameters.Add(new NameValueHeaderValue(RestControlFlags.ElementTypeReserved, string.Format("\"{0}\"", parameterValue))); } } }
public void AddActionResultRepresentationParameter(MediaTypeHeaderValue mediaType, RestControlFlags flags) { INakedObjectSpecificationSurface resultSpec = action.ReturnType; bool isCollection = resultSpec.IsCollection() && !resultSpec.IsParseable(); INakedObjectSpecificationSurface parameterValueSpec = isCollection ? action.ElementType : resultSpec; string parameterValue = GetParameterValue(flags, parameterValueSpec); if (parameterValue != null) { string parameterType = isCollection ? RestControlFlags.ElementTypeReserved : RestControlFlags.DomainTypeReserved; mediaType.Parameters.Add(new NameValueHeaderValue(parameterType, string.Format("\"{0}\"", parameterValue))); } }