public static InlineCollectionRepresentation Create(IOidStrategy oidStrategy, HttpRequest req, PropertyContextFacade propertyContext, IList <OptionalProperty> optionals, RestControlFlags flags, bool asTableColumn) { var collectionRepresentationStrategy = AbstractCollectionRepresentationStrategy.GetStrategy(asTableColumn, true, oidStrategy, req, propertyContext, flags); var size = collectionRepresentationStrategy.GetSize(); if (size != null) { optionals.Add(new OptionalProperty(JsonPropertyNames.Size, size)); } var value = collectionRepresentationStrategy.GetValue(); if (value != null) { optionals.Add(new OptionalProperty(JsonPropertyNames.Value, value)); } var actions = collectionRepresentationStrategy.GetActions(); if (actions.Any()) { var members = RestUtils.CreateMap(actions.ToDictionary(m => m.Id, m => (object)m)); optionals.Add(new OptionalProperty(JsonPropertyNames.Members, members)); } return(optionals.Any() ? CreateWithOptionals <InlineCollectionRepresentation>(new object[] { oidStrategy, collectionRepresentationStrategy }, optionals) : new InlineCollectionRepresentation(oidStrategy, collectionRepresentationStrategy)); }
public static CollectionRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, IList <OptionalProperty> optionals, RestControlFlags flags) { var collectionRepresentationStrategy = AbstractCollectionRepresentationStrategy.GetStrategy(false, false, oidStrategy, req, propertyContext, flags); var value = collectionRepresentationStrategy.GetValue(); if (value != null) { optionals.Add(new OptionalProperty(JsonPropertyNames.Value, value)); } var actions = collectionRepresentationStrategy.GetActions(); if (actions.Length > 0) { var members = RestUtils.CreateMap(actions.ToDictionary(m => m.Id, m => (object)m)); optionals.Add(new OptionalProperty(JsonPropertyNames.Members, members)); } if (optionals.Count == 0) { return(new CollectionRepresentation(oidStrategy, collectionRepresentationStrategy)); } return(CreateWithOptionals <CollectionRepresentation>(new object[] { oidStrategy, collectionRepresentationStrategy }, optionals)); }
protected InlineCollectionRepresentation(IOidStrategy oidStrategy, AbstractCollectionRepresentationStrategy strategy) : base(oidStrategy, strategy.GetFlags()) { MemberType = MemberTypes.Collection; Id = strategy.GetId(); Links = strategy.GetLinks(true); Extensions = strategy.GetExtensions(); SetHeader(strategy.GetTarget()); }
protected CollectionRepresentation(IOidStrategy oidStrategy, AbstractCollectionRepresentationStrategy strategy) : base(oidStrategy, strategy) => Extensions = strategy.GetExtensions();