public static UserRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, IPrincipal user, RestControlFlags flags) { return(new UserRepresentation(oidStrategy, req, user, flags)); }
public override object GetPropertyValue(IOidStrategy oidStrategy, HttpRequestMessage req, IAssociationFacade property, IObjectFacade target, RestControlFlags flags, bool valueOnly, bool useDateOverDateTime) { // todo minimise this return(Representation.GetPropertyValue(oidStrategy, req, property, target, flags, valueOnly, useDateOverDateTime)); }
public static ParameterTypeRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, ParameterTypeContextFacade parameterTypeContext, RestControlFlags flags) { if (!parameterTypeContext.Parameter.Specification.IsParseable) { return(new ParameterTypeRepresentation(oidStrategy, req, parameterTypeContext, flags)); } var exts = new Dictionary <string, object>(); AddStringProperties(parameterTypeContext.Parameter.Specification, parameterTypeContext.Parameter.MaxLength, parameterTypeContext.Parameter.Pattern, exts); OptionalProperty[] parms = exts.Select(e => new OptionalProperty(e.Key, e.Value)).ToArray(); return(CreateWithOptionals <ParameterTypeRepresentation>(new object[] { oidStrategy, req, parameterTypeContext, flags }, parms)); }
public FormActionRepresentationStrategy(IOidStrategy oidStrategy, HttpRequest req, ActionContextFacade actionContext, RestControlFlags flags) : base(oidStrategy, req, actionContext, flags) { }
public CollectionRepresentationStrategy(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(req, propertyContext, flags) { collection = propertyContext.Property.GetNakedObject(propertyContext.Target); }
public static ObjectRepresentation Create(IOidStrategy oidStrategy, IObjectFacade target, HttpRequestMessage req, RestControlFlags flags) { ObjectContextFacade oc = target.FrameworkFacade.GetObject(target); return(Create(oidStrategy, oc, req, flags)); }
private static ObjectRepresentation CreateObjectWithOptionals(IOidStrategy oidStrategy, ObjectContextFacade objectContext, HttpRequestMessage req, RestControlFlags flags) { IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectContext.Target); var props = new List <OptionalProperty>(); if (objectContext.Specification.IsService) { props.Add(new OptionalProperty(JsonPropertyNames.ServiceId, oid.DomainType)); } else { props.Add(new OptionalProperty(JsonPropertyNames.InstanceId, oid.InstanceId)); props.Add(new OptionalProperty(JsonPropertyNames.DomainType, oid.DomainType)); } return(CreateWithOptionals <ObjectRepresentation>(new object[] { oidStrategy, req, objectContext, flags }, props)); }
protected MenuRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, IMenuFacade menu, RestControlFlags flags) : base(oidStrategy, flags) { var helper = new UriMtHelper(oidStrategy, req, menu); SetScalars(menu); SelfRelType = new MenuRelType(RelValues.Self, helper); SetLinksAndMembers(req, menu); SetExtensions(menu); SetHeader(menu); }
public static CollectionRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, IList <OptionalProperty> optionals, RestControlFlags flags) { var collectionRepresentationStrategy = new CollectionRepresentationStrategy(oidStrategy, req, propertyContext, flags); if (optionals.Count == 0) { return(new CollectionRepresentation(oidStrategy, collectionRepresentationStrategy)); } return(CreateWithOptionals <CollectionRepresentation>(new object[] { oidStrategy, collectionRepresentationStrategy }, optionals)); }
public static RefValueRepresentation Create(RelType relType, RestControlFlags flags) { return(new RefValueRepresentation(relType, flags)); }
public static MenuRepresentation Create(IOidStrategy oidStrategy, IMenuFacade menu, HttpRequestMessage req, RestControlFlags flags) { return(new MenuRepresentation(oidStrategy, req, menu, flags)); }
protected RefValueRepresentation(RelType relType, RestControlFlags flags) : base(flags) { Href = relType.GetUri().AbsoluteUri; }
protected MemberRepresentationStrategy(HttpRequestMessage req, PropertyContextSurface propertyContext, RestControlFlags flags) : base(flags) { this.req = req; this.propertyContext = propertyContext; objectUri = new UriMtHelper(req, propertyContext); self = new MemberRelType(RelValues.Self, new UriMtHelper(req, propertyContext)); }
public static MemberAbstractRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, RestControlFlags flags) { IConsentFacade consent = propertyContext.Property.IsUsable(propertyContext.Target); var optionals = new List <OptionalProperty>(); if (consent.IsVetoed) { optionals.Add(new OptionalProperty(JsonPropertyNames.DisabledReason, consent.Reason)); } if (propertyContext.Property.IsCollection) { return(CollectionRepresentation.Create(oidStrategy, req, propertyContext, optionals, flags)); } return(PropertyRepresentation.Create(oidStrategy, req, propertyContext, optionals, flags)); }
public static VersionRepresentation Create(HttpRequestMessage req, IDictionary <string, string> capabilities, RestControlFlags flags) { return(new VersionRepresentation(req, capabilities, flags)); }
protected RefValueRepresentation(IOidStrategy oidStrategy, RelType relType, RestControlFlags flags) : base(oidStrategy, flags) => Href = relType.GetUri().AbsoluteUri;
protected ObjectRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, ObjectContextFacade objectContext, RestControlFlags flags) : base(oidStrategy, flags) { var objectUri = GetHelper(oidStrategy, req, objectContext); SetScalars(objectContext); SelfRelType = objectContext.Specification.IsService ? new ServiceRelType(RelValues.Self, objectUri) : new ObjectRelType(RelValues.Self, objectUri); SetLinksAndMembers(req, objectContext); SetExtensions(objectContext.Target); SetHeader(objectContext); }
public static ActionRepresentation Create(IOidStrategy oidStrategy, HttpRequest req, ActionContextFacade actionContext, RestControlFlags flags) { var actionRepresentationStrategy = AbstractActionRepresentationStrategy.GetStrategy(false, oidStrategy, req, actionContext, flags); return(new ActionRepresentation(oidStrategy, actionRepresentationStrategy)); }
public static ObjectRepresentation Create(IOidStrategy oidStrategy, ObjectContextFacade objectContext, HttpRequestMessage req, RestControlFlags flags) { if (objectContext.Target != null && (objectContext.Specification.IsService || !IsProtoPersistent(objectContext.Target))) { return(CreateObjectWithOptionals(oidStrategy, objectContext, req, flags)); } return(new ObjectRepresentation(oidStrategy, req, objectContext, flags)); }
private static MapRepresentation GetMap(IOidStrategy oidStrategy, HttpRequestMessage req, ContextFacade context, RestControlFlags flags) { MapRepresentation value; // All reasons why we cannot create a linkrep if (context.Specification.IsParseable || context.Specification.IsCollection || context.ProposedValue == null || context.ProposedObjectFacade == null || context.ProposedObjectFacade.Specification.IsParseable) { value = CreateMap(context, context.ProposedValue); } else { value = CreateMap(context, RefValueRepresentation.Create(oidStrategy, new ObjectRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, context.ProposedObjectFacade)), flags)); } return(value); }
public static PropertyRepresentation Create(IOidStrategy oidStrategy, HttpRequest req, PropertyContextFacade propertyContext, IList <OptionalProperty> optionals, RestControlFlags flags) { var strategy = AbstractPropertyRepresentationStrategy.GetStrategy(false, oidStrategy, req, propertyContext, flags); if (!RestUtils.IsBlobOrClob(propertyContext.Specification) && !RestUtils.IsAttachment(propertyContext.Specification)) { optionals.Add(new OptionalProperty(JsonPropertyNames.Value, strategy.GetPropertyValue(oidStrategy, req, propertyContext.Property, propertyContext.Target, flags, false, strategy.UseDateOverDateTime()))); } RestUtils.AddChoices(oidStrategy, req, propertyContext, optionals, flags); return(CreateWithOptionals <PropertyRepresentation>(new object[] { oidStrategy, strategy }, optionals)); }
public static MapRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, ContextFacade context, Format format, RestControlFlags flags, MediaTypeHeaderValue mt) { var objectContext = context as ObjectContextFacade; var actionResultContext = context as ActionResultContextFacade; MapRepresentation mapRepresentation; if (objectContext != null) { List <OptionalProperty> optionalProperties = objectContext.VisibleProperties.Where(p => p.Reason != null || p.ProposedValue != null).Select(c => new OptionalProperty(c.Id, GetMap(oidStrategy, req, c, flags))).ToList(); if (!string.IsNullOrEmpty(objectContext.Reason)) { optionalProperties.Add(new OptionalProperty(JsonPropertyNames.XRoInvalidReason, objectContext.Reason)); } mapRepresentation = Create(optionalProperties.ToArray()); } else if (actionResultContext != null) { List <OptionalProperty> optionalProperties = actionResultContext.ActionContext.VisibleParameters.Select(c => new OptionalProperty(c.Id, GetMap(oidStrategy, req, c, flags))).ToList(); if (!string.IsNullOrEmpty(actionResultContext.Reason)) { optionalProperties.Add(new OptionalProperty(JsonPropertyNames.XRoInvalidReason, actionResultContext.Reason)); } mapRepresentation = Create(optionalProperties.ToArray()); } else { mapRepresentation = GetMap(oidStrategy, req, context, flags); } mapRepresentation.SetContentType(mt); return(mapRepresentation); }
public override object GetPropertyValue(IOidStrategy oidStrategy, HttpRequest req, IAssociationFacade property, IObjectFacade target, RestControlFlags flags, bool valueOnly, bool useDateOverDateTime) => Representation.GetPropertyValue(oidStrategy, req, property, target, flags, valueOnly, useDateOverDateTime);
public static MapRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, IList <ContextFacade> contexts, Format format, RestControlFlags flags, MediaTypeHeaderValue mt) { OptionalProperty[] memberValues = contexts.Select(c => new OptionalProperty(c.Id, GetMap(oidStrategy, req, c, flags))).ToArray(); IObjectFacade target = contexts.First().Target; MapRepresentation mapRepresentation; if (format == Format.Full) { var tempProperties = new List <OptionalProperty>(); if (flags.SimpleDomainModel) { var dt = new OptionalProperty(JsonPropertyNames.DomainType, target.Specification.DomainTypeName(oidStrategy)); tempProperties.Add(dt); } if (flags.FormalDomainModel) { var links = new OptionalProperty(JsonPropertyNames.Links, new[] { Create(new OptionalProperty(JsonPropertyNames.Rel, RelValues.DescribedBy), new OptionalProperty(JsonPropertyNames.Href, new UriMtHelper(oidStrategy, req, target.Specification).GetDomainTypeUri())) }); tempProperties.Add(links); } var members = new OptionalProperty(JsonPropertyNames.Members, Create(memberValues)); tempProperties.Add(members); mapRepresentation = Create(tempProperties.ToArray()); } else { mapRepresentation = Create(memberValues); } mapRepresentation.SetContentType(mt); return(mapRepresentation); }
public PropertyTableRowRepresentationStrategy(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, RestControlFlags flags) : base(oidStrategy, req, propertyContext, flags) { }
public CollectionMemberNotCountedRepresentationStrategy(IOidStrategy oidStrategy, HttpRequest req, PropertyContextFacade propertyContext, RestControlFlags flags) : base(oidStrategy, req, propertyContext, flags) { }
public static InlineCollectionRepresentation Create(IOidStrategy oidStrategy, HttpRequestMessage req, PropertyContextFacade propertyContext, IList <OptionalProperty> optionals, RestControlFlags flags, bool asTableColumn) { var collectionRepresentationStrategy = AbstractCollectionRepresentationStrategy.GetStrategy(asTableColumn, true, oidStrategy, req, propertyContext, flags); int?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.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 InlineCollectionRepresentation(oidStrategy, collectionRepresentationStrategy)); } return(CreateWithOptionals <InlineCollectionRepresentation>(new object[] { oidStrategy, collectionRepresentationStrategy }, optionals)); }
private VersionRepresentation(HttpRequestMessage req, IDictionary <string, string> capabilitiesMap, RestControlFlags flags) : base(flags) { SelfRelType = new VersionRelType(RelValues.Self, new UriMtHelper(req)); SetScalars(); SetLinks(new HomePageRelType(RelValues.Up, new UriMtHelper(req))); SetOptionalCapabilities(capabilitiesMap); SetExtensions(); SetHeader(); }
protected ParameterTypeRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, ParameterTypeContextFacade parameterTypeContext, RestControlFlags flags) : base(oidStrategy, flags) { SetScalars(parameterTypeContext); SelfRelType = new ParamTypeRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, parameterTypeContext)); SetLinks(req, parameterTypeContext); SetExtensions(); SetHeader(); }
private UserRepresentation(IOidStrategy oidStrategy, HttpRequestMessage req, IPrincipal user, RestControlFlags flags) : base(oidStrategy, flags) { SelfRelType = new UserRelType(RelValues.Self, new UriMtHelper(oidStrategy, req)); SetLinks(new HomePageRelType(RelValues.Up, new UriMtHelper(oidStrategy, req))); SetScalars(user); SetExtensions(); SetHeader(); }