private LinkRepresentation CreatePromptLink(HttpRequestMessage req, IObjectFacade objectFacade, IActionParameterFacade parameter) {
            var opts = new List<OptionalProperty>();

            var parameterContext = new ParameterContextFacade {
                Action = parameter.Action,
                Target = objectFacade,
                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, ITypeFacade>[] parms = parameter.GetChoicesParameters();
                OptionalProperty[] args = parms.Select(tuple => RestUtils.CreateArgumentProperty(OidStrategy ,req, tuple, Flags)).ToArray();
                var arguments = new OptionalProperty(JsonPropertyNames.Arguments, MapRepresentation.Create(args));
                opts.Add(arguments);
            }

            return LinkRepresentation.Create(OidStrategy ,new PromptRelType(new UriMtHelper(OidStrategy ,req, parameterContext)), Flags, opts.ToArray());
        }
 public ParameterContextFacade ToParameterContextFacade(IFrameworkFacade facade, INakedObjectsFramework framework) {
     var pc = new ParameterContextFacade {
         Parameter = new ActionParameterFacade(Parameter, facade, framework, OverloadedUniqueId ?? ""),
         Action = new ActionFacade(Action, facade, framework, OverloadedUniqueId ?? "")
     };
     return ToContextFacade(pc, facade, framework);
 }
 public ParameterContextFacade ToParameterContextFacade(IFrameworkFacade facade) {
     var pc = new ParameterContextFacade {
         Parameter = new ActionParameterFacade(Parameter, Target, facade),
         Target = new ObjectFacade(Target, facade),
         Action = new ActionFacade(Action, Target, facade)
     };
     return ToContextFacade(pc, facade);
 }
 protected PromptRepresentation(IOidStrategy oidStrategy, ParameterContextFacade parmContext, HttpRequestMessage req, RestControlFlags flags)
     : base(oidStrategy, flags) {
     SetScalars(parmContext.Id);
     SetChoices(parmContext, req);
     SelfRelType = new PromptRelType(RelValues.Self, new UriMtHelper(oidStrategy, req, parmContext));
     var helper = new UriMtHelper(oidStrategy, req, parmContext.Target);
     ObjectRelType parentRelType = parmContext.Target.Specification.IsService ? new ServiceRelType(RelValues.Up, helper) : new ObjectRelType(RelValues.Up, helper);
     SetLinks(req, parmContext.Completions.ElementType, parentRelType);
     SetExtensions();
     SetHeader(parmContext.Completions.IsListOfServices);
 }
        public UriMtHelper GetHelper(IOidStrategy oidStrategy, HttpRequestMessage req, IObjectFacade objectFacade) {
            if (parameter != null) {
                var parameterContext = new ParameterContextFacade {
                    Action = parameter.Action,
                    Target = objectFacade,
                    Parameter = parameter
                };
                return new UriMtHelper(oidStrategy, req, parameterContext);
            }

            return new UriMtHelper(oidStrategy, req, association);
        }
 public RestSnapshot(IOidStrategy oidStrategy, ParameterContextFacade parmContext, HttpRequestMessage req, RestControlFlags flags)
     : this(oidStrategy, req, true) {
     populator = () => {
         Representation = PromptRepresentation.Create(oidStrategy, parmContext, req, flags);
         SetHeaders();
     };
 }
 public RestSnapshot(IOidStrategy oidStrategy, ParameterContextFacade parmContext, ListContextFacade listContext, HttpRequestMessage req, RestControlFlags flags)
     : this(oidStrategy,req, true) {
     logger.DebugFormat("RestSnapshot:parameterprompt");
     populator = () => {
         representation = PromptRepresentation.Create(oidStrategy, parmContext, listContext, req, flags);
         SetHeaders();
     };
 }
 private LinkRepresentation CreateActionParamLink(ParameterContextFacade p) {
     return LinkRepresentation.Create(OidStrategy, new ParamTypeRelType(new UriMtHelper(OidStrategy, req,
         new ParameterTypeContextFacade {
             Action = actionContext.Action,
             OwningSpecification = actionContext.Target.Specification,
             Parameter = p.Parameter
         })), Flags,
         new OptionalProperty(JsonPropertyNames.Id, p.Id));
 }
 public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, ParameterContextFacade parameterContext)
     : this(oidStrategy ,req) {
     action = parameterContext.Action;
     param = parameterContext.Parameter;
     objectFacade = parameterContext.Target;
     spec = objectFacade.Specification;
     IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade);
     cachedId = oid.InstanceId;
     CachedType = oid.DomainType;
 }
 public static Representation Create(IOidStrategy oidStrategy, ParameterContextFacade parmContext, HttpRequestMessage req, RestControlFlags flags) {
     return new PromptRepresentation(oidStrategy, parmContext, req, flags);
 }
 private void SetChoices(ParameterContextFacade paramContext, HttpRequestMessage req) {
     Choices = paramContext.Completions.List.Select(c => RestUtils.GetChoiceValue(OidStrategy, req, c, paramContext.Parameter, Flags)).ToArray();
 }
 public UriMtHelper(IOidStrategy oidStrategy, HttpRequestMessage req, ParameterContextFacade parameterContext)
     : this(oidStrategy, req) {
     action = parameterContext.Action;
     param = parameterContext.Parameter;
     objectFacade = parameterContext.Target;
     spec = objectFacade.Specification;
     if (objectFacade.Specification.IsParseable) {
         throw new ArgumentException($"Cannot build URI  for parseable specification : {objectFacade.Specification.FullName}");
     }
     IOidTranslation oid = oidStrategy.FrameworkFacade.OidTranslator.GetOidTranslation(objectFacade);
     cachedId = oid.InstanceId;
     CachedType = oid.DomainType;
 }