public ErrorRepresentation(Exception e) : base(RestControlFlags.DefaultFlags()) { Exception exception = GetInnermostException(e); Message = exception.Message; StackTrace = exception.StackTrace.Split('\n').Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); Links = new LinkRepresentation[] {}; Extensions = new MapRepresentation(); }
private void SetLinks(HttpRequestMessage req, ActionResultContextSurface actionResult) { if (actionResult.ActionContext.Action.IsQueryOnly()) { Links = new[] {LinkRepresentation.Create(SelfRelType, Flags, new OptionalProperty(JsonPropertyNames.Arguments, CreateArguments(req, actionResult)))}; } else { Links = new LinkRepresentation[] {}; } }
private void SetLinks(HttpRequestMessage req) { Links = new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags), LinkRepresentation.Create(OidStrategy, new HomePageRelType(RelValues.Up, new UriMtHelper(OidStrategy, req)), Flags) }; }
private LinkRepresentation CreateDomainLink(IOidStrategy oidStrategy, HttpRequestMessage req, ITypeFacade spec) { return(LinkRepresentation.Create(oidStrategy, new DomainTypeRelType(new UriMtHelper(oidStrategy, req, spec)), Flags)); }
private void SetLinks(HomePageRelType homePageRelType) { Links = new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags), LinkRepresentation.Create(OidStrategy, homePageRelType, Flags) }; }
private void SetMembers(ITypeFacade spec, HttpRequestMessage req) { IAssociationFacade[] properties = spec.Properties.Where(p => !p.IsCollection).ToArray(); IAssociationFacade[] collections = spec.Properties.Where(p => p.IsCollection).ToArray(); IActionFacade[] actions = spec.GetActionLeafNodes(); IEnumerable <LinkRepresentation> propertyMembers = properties.Select(p => LinkRepresentation.Create(OidStrategy, new TypeMemberRelType(RelValues.Property, new UriMtHelper(OidStrategy, req, new PropertyTypeContextFacade { Property = p, OwningSpecification = spec })), Flags)); IEnumerable <LinkRepresentation> collectionMembers = collections.Select(c => LinkRepresentation.Create(OidStrategy, new TypeMemberRelType(RelValues.Collection, new UriMtHelper(OidStrategy, req, new PropertyTypeContextFacade { Property = c, OwningSpecification = spec })), Flags)); IEnumerable <LinkRepresentation> actionMembers = actions.Select(a => LinkRepresentation.Create(OidStrategy, new TypeMemberRelType(RelValues.Action, new UriMtHelper(OidStrategy, req, new ActionTypeContextFacade { ActionContext = new ActionContextFacade { Action = a }, OwningSpecification = spec })), Flags)); Members = propertyMembers.Union(collectionMembers).Union(actionMembers).ToArray(); }
private void SetLinks(HttpRequestMessage req, ActionResultContextFacade actionResult) { Links = actionResult.ActionContext.Action.IsQueryOnly ? new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags, new OptionalProperty(JsonPropertyNames.Arguments, CreateArguments(req, actionResult))) } : new LinkRepresentation[] {}; }
private LinkRepresentation CreateDomainLink(HttpRequestMessage req, INakedObjectSpecificationSurface spec) { return(LinkRepresentation.Create(new DomainTypeRelType(new UriMtHelper(req, spec)), Flags)); }
private static LinkRepresentation CreateDefaultLink(HttpRequestMessage req, INakedObjectActionParameterSurface parameter, INakedObjectSurface defaultNakedObject, string title, RestControlFlags flags) { return(LinkRepresentation.Create(new DefaultRelType(parameter, new UriMtHelper(req, defaultNakedObject)), flags, new OptionalProperty(JsonPropertyNames.Title, title))); }
private static LinkRepresentation CreateDefaultLink(IOidStrategy oidStrategy, HttpRequestMessage req, IActionParameterFacade parameter, IObjectFacade defaultNakedObject, string title, RestControlFlags flags) { return(LinkRepresentation.Create(oidStrategy, new DefaultRelType(parameter, new UriMtHelper(oidStrategy, req, defaultNakedObject)), flags, new OptionalProperty(JsonPropertyNames.Title, title))); }
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(); }