コード例 #1
0
        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();
        }
コード例 #2
0
 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[] {};
     }
 }
コード例 #3
0
 private void SetLinks(HttpRequestMessage req)
 {
     Links = new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags), LinkRepresentation.Create(OidStrategy, new HomePageRelType(RelValues.Up, new UriMtHelper(OidStrategy, req)), Flags) };
 }
コード例 #4
0
 private LinkRepresentation CreateDomainLink(IOidStrategy oidStrategy, HttpRequestMessage req, ITypeFacade spec)
 {
     return(LinkRepresentation.Create(oidStrategy, new DomainTypeRelType(new UriMtHelper(oidStrategy, req, spec)), Flags));
 }
コード例 #5
0
 private void SetLinks(HomePageRelType homePageRelType)
 {
     Links = new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags), LinkRepresentation.Create(OidStrategy, homePageRelType, Flags) };
 }
コード例 #6
0
        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();
        }
コード例 #7
0
 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[] {};
 }
コード例 #8
0
 private LinkRepresentation CreateDomainLink(HttpRequestMessage req, INakedObjectSpecificationSurface spec)
 {
     return(LinkRepresentation.Create(new DomainTypeRelType(new UriMtHelper(req, spec)), Flags));
 }
コード例 #9
0
 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)));
 }
コード例 #10
0
 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)));
 }
コード例 #11
0
        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();
        }