Example #1
0
        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());
        }
Example #2
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();
     };
 }
Example #3
0
 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);
 }
Example #4
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));
 }
Example #5
0
 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;
 }
Example #6
0
 public static Representation Create(ParameterContextSurface parmContext, ListContextSurface listContext, HttpRequestMessage req, RestControlFlags flags) {
     return new PromptRepresentation(parmContext, listContext, req, flags);
 }
Example #7
0
 private void SetChoices(ListContextSurface listContext, ParameterContextSurface paramContext, HttpRequestMessage req) {
     Choices = listContext.List.Select(c => RestUtils.GetChoiceValue(req, c, paramContext.Parameter, Flags)).ToArray();
 }