Beispiel #1
0
 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();
 }
Beispiel #2
0
 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();
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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();
            };
        }
Beispiel #7
0
 public UriMtHelper(HttpRequestMessage req, ParameterTypeContextSurface parameterTypeContext)
     : this(req) {
     action = parameterTypeContext.Action;
     spec = parameterTypeContext.OwningSpecification;
     param = parameterTypeContext.Parameter;
     cachedId = "";
     cachedType = spec.DomainTypeName();
 }