private LinkRepresentation CreateClearLink() { return(LinkRepresentation.Create(OidStrategy, new MemberRelType(RelValues.Clear, GetHelper()) { Method = RelMethod.Delete }, Flags)); }
public static object GetChoiceValue(INakedObjectSurface item, ChoiceRelType relType, RestControlFlags flags) { string title = SafeGetTitle(item); object value = ObjectToPredefinedType(item.Object); return(item.Specification.IsParseable() ? value : LinkRepresentation.Create(relType, flags, new OptionalProperty(JsonPropertyNames.Title, title))); }
public static object GetChoiceValue(IOidStrategy oidStrategy, IObjectFacade item, Func <ChoiceRelType> relType, RestControlFlags flags) { string title = SafeGetTitle(item); object value = ObjectToPredefinedType(item.Object); return(item.Specification.IsParseable ? value : LinkRepresentation.Create(oidStrategy, relType(), flags, new OptionalProperty(JsonPropertyNames.Title, title))); }
private static LinkRepresentation CreateTableRowValueLink(IObjectFacade no, string[] columns, RelType rt, IOidStrategy oidStrategy, HttpRequestMessage req, RestControlFlags flags) { var optionals = new List <OptionalProperty> { new OptionalProperty(JsonPropertyNames.Title, SafeGetTitle(no)) }; columns = columns ?? no.Specification.Properties.Select(p => p.Id).ToArray(); var properties = columns.Select(c => no.Specification.Properties.SingleOrDefault(p => p.Id == c)).Where(p => p != null && p.IsVisible(no)).Select(p => new PropertyContextFacade { Property = p, Target = no }); var propertyReps = properties.Select(p => InlineMemberAbstractRepresentation.Create(oidStrategy, req, p, flags, true)).ToArray(); var members = CreateMap(propertyReps.ToDictionary(m => m.Id, m => (object)m)); optionals.Add(new OptionalProperty(JsonPropertyNames.Members, members)); return(LinkRepresentation.Create(oidStrategy, rt, flags, optionals.ToArray())); }
private LinkRepresentation CreateUpLink() { var helper = new UriMtHelper(req, actionContext.Target); ObjectRelType parentRelType = actionContext.Target.Specification.IsService() ? new ServiceRelType(RelValues.Up, helper) : new ObjectRelType(RelValues.Up, helper); return(LinkRepresentation.Create(parentRelType, Flags)); }
protected LinkRepresentation CreateUpLink() { var helper = new UriMtHelper(OidStrategy, Req, ActionContext.Target); var parentRelType = ActionContext.Target.Specification.IsService ? new ServiceRelType(RelValues.Up, helper) : new ObjectRelType(RelValues.Up, helper); return(LinkRepresentation.Create(OidStrategy, parentRelType, Flags)); }
private LinkRepresentation CreateClearLink() { return(LinkRepresentation.Create(OidStrategy, new MemberRelType(RelValues.Clear, new UriMtHelper(OidStrategy, req, propertyContext)) { Method = RelMethod.Delete }, Flags)); }
private LinkRepresentation CreateDescribedByLink() { return(LinkRepresentation.Create(OidStrategy, new TypeMemberRelType(RelValues.DescribedBy, new UriMtHelper(OidStrategy, req, new PropertyTypeContextFacade { Property = propertyContext.Property, OwningSpecification = propertyContext.Target.Specification })), Flags)); }
private LinkRepresentation CreateModifyLink() { return(LinkRepresentation.Create(OidStrategy, new MemberRelType(RelValues.Modify, new UriMtHelper(OidStrategy, req, propertyContext)) { Method = RelMethod.Put }, Flags, new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object)))))); }
private LinkRepresentation CreateDescribedByLink() { return(LinkRepresentation.Create(new TypeMemberRelType(RelValues.DescribedBy, new UriMtHelper(req, new ActionTypeContextSurface { ActionContext = actionContext, OwningSpecification = actionContext.Target.Specification })), Flags)); }
private LinkRepresentation CreateActionParamLink(ParameterContextFacade p) { return(LinkRepresentation.Create(OidStrategy, new ParamTypeRelType(new UriMtHelper(OidStrategy, req, new ParameterTypeContextFacade { Action = actionContext.Action, OwningSpecification = actionContext.Target.Specification, Parameter = p.Parameter })), Flags, new OptionalProperty(JsonPropertyNames.Id, p.Id))); }
private LinkRepresentation CreateDetailsLink() { var opts = new List <OptionalProperty>(); if (propertyContext.Property.IsEager(propertyContext.Target)) { opts.Add(new OptionalProperty(JsonPropertyNames.Value, MemberAbstractRepresentation.Create(OidStrategy, req, propertyContext, Flags))); } return(LinkRepresentation.Create(OidStrategy, new MemberRelType(new UriMtHelper(OidStrategy, req, propertyContext)), Flags, opts.ToArray())); }
public static OptionalProperty CreateArgumentProperty(HttpRequestMessage req, Tuple <string, INakedObjectSpecificationSurface> pnt, RestControlFlags flags) { var tempLinks = new List <LinkRepresentation>(); if (flags.FormalDomainModel) { tempLinks.Add(LinkRepresentation.Create(new DomainTypeRelType(RelValues.DescribedBy, new UriMtHelper(req, pnt.Item2)), flags)); } return(new OptionalProperty(pnt.Item1, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object)), new OptionalProperty(JsonPropertyNames.Links, tempLinks.ToArray())))); }
private LinkRepresentation CreateActionLink() { List <OptionalProperty> optionalProperties = parameterList.Select(pr => new OptionalProperty(pr.Name, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object))))).ToList(); RelMethod method = GetRelMethod(); return(LinkRepresentation.Create(new InvokeRelType(new UriMtHelper(req, actionContext)) { Method = method }, Flags, new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(optionalProperties.ToArray())))); }
protected virtual LinkRepresentation CreateActionLink() { var optionalProperties = parameterList.Select(pr => new OptionalProperty(pr.Name, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object))))).ToList(); var method = GetRelMethod(); return(LinkRepresentation.Create(OidStrategy, new InvokeRelType(new UriMtHelper(OidStrategy, Req, ActionContext)) { Method = method }, Flags, new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(optionalProperties.ToArray())))); }
private LinkRepresentation CreatePromptLink() { var opts = new List <OptionalProperty>(); if (propertyContext.Property.IsAutoCompleteEnabled) { var arguments = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.XRoSearchTerm, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object)))))); var extensions = new OptionalProperty(JsonPropertyNames.Extensions, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.MinLength, propertyContext.Property.AutoCompleteMinLength))); opts.Add(arguments); opts.Add(extensions); } else { Tuple <string, ITypeFacade>[] parms = propertyContext.Property.GetChoicesParameters(); OptionalProperty[] args = parms.Select(pnt => RestUtils.CreateArgumentProperty(OidStrategy, req, pnt, Flags)).ToArray(); var arguments = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(args)); opts.Add(arguments); } return(LinkRepresentation.Create(OidStrategy, new PromptRelType(new UriMtHelper(OidStrategy, req, propertyContext)), Flags, opts.ToArray())); }
protected LinkRepresentation CreatePersistPromptLink() { var opts = new List <OptionalProperty>(); var ids = PropertyContext.Target.Specification.Properties.Where(p => !p.IsCollection && !p.IsInline).ToDictionary(p => p.Id, p => GetPropertyValue(OidStrategy, Req, p, PropertyContext.Target, Flags, true, UseDateOverDateTime())).ToArray(); var props = ids.Select(kvp => new OptionalProperty(kvp.Key, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, kvp.Value)))).ToArray(); var objectMembers = new OptionalProperty(JsonPropertyNames.PromptMembers, MapRepresentation.Create(props)); if (PropertyContext.Property.IsAutoCompleteEnabled) { var searchTerm = new OptionalProperty(JsonPropertyNames.XRoSearchTerm, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object)))); var arguments = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(objectMembers, searchTerm)); var extensions = new OptionalProperty(JsonPropertyNames.Extensions, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.MinLength, PropertyContext.Property.AutoCompleteMinLength))); opts.Add(arguments); opts.Add(extensions); } else { var parms = PropertyContext.Property.GetChoicesParameters(); var conditionalArguments = parms.Select(pnt => RestUtils.CreateArgumentProperty(OidStrategy, Req, pnt, Flags)); var args = new List <OptionalProperty> { objectMembers }; args.AddRange(conditionalArguments); var arguments = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(args.ToArray())); opts.Add(arguments); } return(LinkRepresentation.Create(OidStrategy, new PromptRelType(GetHelper()) { Method = RelMethod.Put }, Flags, opts.ToArray())); }
private LinkRepresentation CreateCollectionValueLink() { return(LinkRepresentation.Create(OidStrategy, new CollectionValueRelType(new UriMtHelper(OidStrategy, req, propertyContext)), Flags)); }
protected LinkRepresentation CreateSelfLink() => LinkRepresentation.Create(OidStrategy, self, Flags);
private LinkRepresentation CreateElementTypeLink() { return(LinkRepresentation.Create(new DomainTypeRelType(RelValues.ElementType, new UriMtHelper(req, actionContext.ElementSpecification)), Flags)); }
protected LinkRepresentation CreateDetailsLink() => LinkRepresentation.Create(OidStrategy, new MemberRelType(new UriMtHelper(OidStrategy, Req, ActionContext)), Flags);
private LinkRepresentation CreateValueLink(INakedObjectSurface no) { return(LinkRepresentation.Create(new ValueRelType(propertyContext.Property, new UriMtHelper(req, no)), Flags, new OptionalProperty(JsonPropertyNames.Title, RestUtils.SafeGetTitle(no)))); }
private LinkRepresentation CreateDetailsLink() { return(LinkRepresentation.Create(OidStrategy, new MemberRelType(new UriMtHelper(OidStrategy, req, actionContext)), Flags)); }
private LinkRepresentation CreateCollectionValueLink() { return(LinkRepresentation.Create(OidStrategy, new CollectionValueRelType(GetHelper()), Flags)); }
private LinkRepresentation CreateUpLink() { return(LinkRepresentation.Create(OidStrategy, new ObjectRelType(RelValues.Up, objectUri), Flags)); }
private LinkRepresentation CreateAttachmentLink() { string title = GetAttachmentFileName(propertyContext); return(LinkRepresentation.Create(OidStrategy, new AttachmentRelType(new UriMtHelper(OidStrategy, req, propertyContext)), Flags, new OptionalProperty(JsonPropertyNames.Title, title))); }
private LinkRepresentation CreateSelfLink() { return(LinkRepresentation.Create(OidStrategy, self, Flags)); }
private LinkRepresentation CreateReturnTypeLink() { return(LinkRepresentation.Create(OidStrategy, new DomainTypeRelType(RelValues.ReturnType, new UriMtHelper(OidStrategy, req, actionContext.Specification)), Flags)); }
protected LinkRepresentation CreateValueLink(IObjectFacade no) => LinkRepresentation.Create(OidStrategy, new ValueRelType(PropertyContext.Property, new UriMtHelper(OidStrategy, Req, no)), Flags, new OptionalProperty(JsonPropertyNames.Title, RestUtils.SafeGetTitle(no)));
protected LinkRepresentation CreateDetailsLink() => LinkRepresentation.Create(OidStrategy, new MemberRelType(helper), Flags);