protected MemberRepresentationStrategy(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, RestControlFlags flags)
     : base(oidStrategy, flags) {
     Req = req;
     PropertyContext = propertyContext;
     objectUri = new UriMtHelper(oidStrategy, req, propertyContext);
     self = new MemberRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, propertyContext));
 }
Пример #2
0
        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 void SetLinks(HttpRequestMessage req, PropertyContextFacade propertyContext, RelType parentRelType) {
            var tempLinks = new List<LinkRepresentation> {
                LinkRepresentation.Create(OidStrategy, parentRelType, Flags),
                LinkRepresentation.Create(OidStrategy, SelfRelType, Flags)
            };

            Links = tempLinks.ToArray();
        }
        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());
        }
 public static LinkRepresentation Create(IOidStrategy oidStrategy, RelType relType, RestControlFlags flags, params OptionalProperty[] properties) {
     return properties.Any() ? CreateWithOptionals<LinkRepresentation>(new object[] {oidStrategy, relType, flags}, properties) : new LinkRepresentation(oidStrategy, relType, flags);
 }
 private void SetScalars(RelType relType) {
     Rel = relType.Name;
     Method = relType.Method.ToString().ToUpper();
     Type = relType.GetMediaType(Flags).ToString();
 }
 protected LinkRepresentation(IOidStrategy oidStrategy, RelType relType, RestControlFlags flags)
     : base(oidStrategy, relType, flags) {
     SetScalars(relType);
 }
 protected AbstractActionRepresentationStrategy(IOidStrategy oidStrategy, HttpRequestMessage req, ActionContextFacade actionContext, RestControlFlags flags)
     : base(oidStrategy, flags) {
     Req = req;
     ActionContext = actionContext;
     self = new MemberRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, actionContext));
 }
 public static RefValueRepresentation Create(IOidStrategy oidStrategy, RelType relType, RestControlFlags flags) {
     return new RefValueRepresentation(oidStrategy, relType, flags);
 }
 protected RefValueRepresentation(IOidStrategy oidStrategy, RelType relType, RestControlFlags flags)
     : base(oidStrategy, flags) {
     Href = relType.GetUri().AbsoluteUri;
 }