private LinkRepresentation CreatePromptLink(HttpRequestMessage req, INakedObjectSurface nakedObject, INakedObjectActionParameterSurface parameter)
        {
            var opts = new List <OptionalProperty>();

            var parameterContext = new ParameterContextSurface {
                Action    = parameter.Action,
                Target    = nakedObject,
                Parameter = parameter
            };

            if (parameter.IsAutoCompleteEnabled)
            {
                var arguments  = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.XRoSearchTerm, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.Value, null, typeof(object))))));
                var extensions = new OptionalProperty(JsonPropertyNames.Extensions, MapRepresentation.Create(new OptionalProperty(JsonPropertyNames.MinLength, parameter.AutoCompleteMinLength())));

                opts.Add(arguments);
                opts.Add(extensions);
            }
            else
            {
                Tuple <string, INakedObjectSpecificationSurface>[] parms = parameter.GetChoicesParameters();
                OptionalProperty[] args = parms.Select(tuple => RestUtils.CreateArgumentProperty(req, tuple, Flags)).ToArray();
                var arguments           = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(args));
                opts.Add(arguments);
            }

            return(LinkRepresentation.Create(new PromptRelType(new UriMtHelper(req, parameterContext)), Flags, opts.ToArray()));
        }
示例#2
0
 public ParameterContextSurface ToParameterContextSurface(INakedObjectsSurface surface) {
     var pc = new ParameterContextSurface {
         Parameter = new NakedObjectActionParameterWrapper(Parameter, surface, OverloadedUniqueId ?? ""),
         Action = new NakedObjectActionWrapper(Action, surface, OverloadedUniqueId ?? "")
     };
     return ToContextSurface(pc, surface);
 }
示例#3
0
 public RestSnapshot(ParameterContextSurface parmContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags)
     : this(req, true)
 {
     logger.DebugFormat("RestSnapshot:parameterprompt");
     populator = () => {
         representation = PromptRepresentation.Create(parmContext, listContext, req, flags);
         SetHeaders();
     };
 }
示例#4
0
        public ParameterContextSurface ToParameterContextSurface(INakedObjectsSurface surface, INakedObjectsFramework framework)
        {
            var pc = new ParameterContextSurface {
                Parameter = new NakedObjectActionParameterWrapper(Parameter, surface, framework, OverloadedUniqueId ?? ""),
                Action    = new NakedObjectActionWrapper(Action, surface, framework, OverloadedUniqueId ?? "")
            };

            return(ToContextSurface(pc, surface, framework));
        }
 public UriMtHelper(HttpRequestMessage req, ParameterContextSurface parameterContext)
     : this(req) {
     action      = parameterContext.Action;
     param       = parameterContext.Parameter;
     nakedObject = parameterContext.Target;
     spec        = nakedObject.Specification;
     LinkObjectId oid = OidStrategyHolder.OidStrategy.GetOid(nakedObject);
     cachedId   = oid.InstanceId;
     cachedType = oid.DomainType;
 }
示例#6
0
 private LinkRepresentation CreateActionParamLink(ParameterContextSurface p)
 {
     return(LinkRepresentation.Create(new ParamTypeRelType(new UriMtHelper(req,
                                                                           new ParameterTypeContextSurface {
         Action = actionContext.Action,
         OwningSpecification = actionContext.Target.Specification,
         Parameter = p.Parameter
     })), Flags,
                                      new OptionalProperty(JsonPropertyNames.Id, p.Id)));
 }
        protected PromptRepresentation(ParameterContextSurface parmContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags)
            : base(flags)
        {
            SetScalars(parmContext.Id);
            SetChoices(listContext, parmContext, req);
            SelfRelType = new PromptRelType(RelValues.Self, new UriMtHelper(req, parmContext));
            var           helper        = new UriMtHelper(req, parmContext.Target);
            ObjectRelType parentRelType = parmContext.Target.Specification.IsService() ? new ServiceRelType(RelValues.Up, helper) : new ObjectRelType(RelValues.Up, helper);

            SetLinks(req, listContext.ElementType, parentRelType);
            SetExtensions();
            SetHeader(listContext.IsListOfServices);
        }
 private void SetChoices(ListContextSurface listContext, ParameterContextSurface paramContext, HttpRequestMessage req)
 {
     Choices = listContext.List.Select(c => RestUtils.GetChoiceValue(req, c, paramContext.Parameter, Flags)).ToArray();
 }
 public static Representation Create(ParameterContextSurface parmContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags)
 {
     return(new PromptRepresentation(parmContext, listContext, req, flags));
 }