protected ParameterTypeRepresentation(HttpRequestMessage req, ParameterTypeContextSurface parameterTypeContext, RestControlFlags flags) : base(flags) { SetScalars(parameterTypeContext); SelfRelType = new ParamTypeRelType(RelValues.Self, new UriMtHelper(req, parameterTypeContext)); SetLinks(req, parameterTypeContext); SetExtensions(); SetHeader(); }
private void SetScalars(ParameterTypeContextSurface parameterTypeContext) { Id = parameterTypeContext.Parameter.Id; Number = parameterTypeContext.Parameter.Number(); Name = parameterTypeContext.Parameter.Id; FriendlyName = parameterTypeContext.Parameter.Name(); Description = parameterTypeContext.Parameter.Description(); Optional = !parameterTypeContext.Parameter.IsMandatory(); }
public static ParameterTypeRepresentation Create(HttpRequestMessage req, ParameterTypeContextSurface parameterTypeContext, RestControlFlags flags) { if (!parameterTypeContext.Parameter.Specification.IsParseable()) { return new ParameterTypeRepresentation(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[] {req, parameterTypeContext, flags}, parms); }
private void SetLinks(HttpRequestMessage req, ParameterTypeContextSurface parameterTypeContext) { var domainTypeUri = new UriMtHelper(req, parameterTypeContext); var tempLinks = new List<LinkRepresentation> { LinkRepresentation.Create(SelfRelType, Flags), LinkRepresentation.Create(new TypeMemberRelType(RelValues.Up, domainTypeUri), Flags), LinkRepresentation.Create(new DomainTypeRelType(RelValues.ReturnType, new UriMtHelper(req, parameterTypeContext.Parameter.Specification)), Flags) }; Links = tempLinks.ToArray(); }
private void SetLinks(HttpRequestMessage req, INakedObjectSurface nakedObject, INakedObjectActionParameterSurface parameter) { var tempLinks = new List<LinkRepresentation>(); if (Flags.FormalDomainModel) { var parameterTypeContextSurface = new ParameterTypeContextSurface { Action = parameter.Action, OwningSpecification = nakedObject.Specification, Parameter = parameter }; LinkRepresentation describedBy = LinkRepresentation.Create(new ParamTypeRelType(RelValues.DescribedBy, new UriMtHelper(req, parameterTypeContextSurface)), Flags); tempLinks.Add(describedBy); } if (parameter.IsAutoCompleteEnabled || parameter.GetChoicesParameters().Any()) { tempLinks.Add(CreatePromptLink(req, nakedObject, parameter)); } Links = tempLinks.ToArray(); }
public RestSnapshot(ParameterTypeContextSurface parameterTypeContext, HttpRequestMessage req, RestControlFlags flags) : this(req, true) { logger.DebugFormat("RestSnapshot:{0}", parameterTypeContext.GetType().FullName); populator = () => { representation = ParameterTypeRepresentation.Create(req, parameterTypeContext, flags); SetHeaders(); }; }
public UriMtHelper(HttpRequestMessage req, ParameterTypeContextSurface parameterTypeContext) : this(req) { action = parameterTypeContext.Action; spec = parameterTypeContext.OwningSpecification; param = parameterTypeContext.Parameter; cachedId = ""; cachedType = spec.DomainTypeName(); }