public ErrorRepresentation(IOidStrategy oidStrategy, Exception e)
            : base(oidStrategy, 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, ObjectContextFacade objectContext) {
     Links = new LinkRepresentation[] {};
 }
示例#3
0
 private void SetLinks(HomePageRelType homePageRelType)
 {
     Links = new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags), LinkRepresentation.Create(OidStrategy, homePageRelType, Flags) };
 }
        private void SetMembers(ObjectContextFacade objectContext, HttpRequest req, List <LinkRepresentation> tempLinks)
        {
            var visiblePropertiesAndCollections = objectContext.VisibleProperties;

            if (!Flags.BlobsClobs)
            {
                // filter any blobs and clobs
                visiblePropertiesAndCollections = visiblePropertiesAndCollections.Where(vp => !RestUtils.IsBlobOrClob(vp.Specification)).ToArray();
            }

            var visibleProperties = visiblePropertiesAndCollections.Where(p => !p.Property.IsCollection).ToArray();

            if (!IsProtoPersistent(objectContext.Target) && !IsForm(objectContext.Target) && visibleProperties.Any(p => p.Property.IsUsable(objectContext.Target).IsAllowed))
            {
                var ids   = visibleProperties.Where(p => p.Property.IsUsable(objectContext.Target).IsAllowed&& !p.Property.IsInline).Select(p => p.Id).ToArray();
                var props = ids.Select(s => new OptionalProperty(s, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object))))).ToArray();

                var helper = GetHelper(OidStrategy, req, objectContext);

                var modifyLink = LinkRepresentation.Create(OidStrategy, new ObjectRelType(RelValues.Update, helper)
                {
                    Method = RelMethod.Put
                }, Flags,
                                                           new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(props)));

                tempLinks.Add(modifyLink);
            }

            if (IsProtoPersistent(objectContext.Target))
            {
                var ids = objectContext.Target.Specification.Properties.Where(p => !p.IsCollection && !p.IsInline).ToDictionary(p => p.Id, p => {
                    var useDate = p.IsDateOnly;
                    return(GetPropertyValue(OidStrategy, req, p, objectContext.Target, Flags, true, useDate));
                }).ToArray();
                var props = ids.Select(kvp => new OptionalProperty(kvp.Key, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, kvp.Value)))).ToArray();

                var argMembers = new OptionalProperty(JsonPropertyNames.Members, MapRepresentation.Create(props));
                var args       = new List <OptionalProperty> {
                    argMembers
                };

                var persistLink = LinkRepresentation.Create(OidStrategy, new ObjectsRelType(RelValues.Persist, new UriMtHelper(OidStrategy, req, objectContext.Target.Specification))
                {
                    Method = RelMethod.Post
                }, Flags,
                                                            new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(args.ToArray())));

                tempLinks.Add(persistLink);
            }

            var properties = visiblePropertiesAndCollections.Select(p => InlineMemberAbstractRepresentation.Create(OidStrategy, req, p, Flags, false)).ToArray();

            ActionContextFacade[] visibleActions;

            if (IsProtoPersistent(objectContext.Target))
            {
                visibleActions = new ActionContextFacade[] { };
            }
            else if (IsForm(objectContext.Target))
            {
                visibleActions = objectContext.VisibleActions.Where(af => af.Action.ParameterCount == 0).ToArray();
            }
            else
            {
                visibleActions = FilterLocallyContributedActions(objectContext.VisibleActions, visiblePropertiesAndCollections.Where(p => p.Property.IsCollection).ToArray());
            }

            var actions = visibleActions.Select(a => InlineActionRepresentation.Create(OidStrategy, req, a, Flags)).ToArray();

            var allMembers = properties.Union(actions);

            Members = RestUtils.CreateMap(allMembers.ToDictionary(m => m.Id, m => (object)m));
        }
示例#5
0
 private void SetLinks(HttpRequest req, ITypeFacade spec) => Links = new LinkRepresentation[]
 {
 };
示例#6
0
 private void SetLinks(HttpRequest req) => Links = new[] { LinkRepresentation.Create(OidStrategy, SelfRelType, Flags), LinkRepresentation.Create(OidStrategy, new HomePageRelType(RelValues.Up, new UriMtHelper(OidStrategy, req)), Flags) };
示例#7
0
        private void SetValue(PropertyContextFacade propertyContext, HttpRequestMessage req, RestControlFlags flags)
        {
            IEnumerable <IObjectFacade> collectionItems = propertyContext.Property.GetValue(propertyContext.Target).ToEnumerable();

            Value = collectionItems.Select(i => LinkRepresentation.Create(OidStrategy, new ValueRelType(propertyContext.Property, new UriMtHelper(OidStrategy, req, i)), flags, new OptionalProperty(JsonPropertyNames.Title, RestUtils.SafeGetTitle(i)))).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[] {};
 }
示例#9
0
 private void SetLinks(HttpRequestMessage req, ITypeFacade spec)
 {
     Links = new LinkRepresentation[] {};
 }
 private void SetLinks(HttpRequestMessage req, ITypeFacade spec) {
     Links = new LinkRepresentation[] {};
 }
 private void SetLinks(HttpRequestMessage req, ObjectContextFacade objectContext)
 {
     Links = new LinkRepresentation[] {};
 }