Esempio n. 1
0
        private void SetLinks(HttpRequest req, IObjectFacade objectFacade, FieldFacadeAdapter parameter)
        {
            var tempLinks = new List <LinkRepresentation>();

            if (parameter.IsAutoCompleteEnabled || parameter.GetChoicesParameters().Any())
            {
                tempLinks.Add(CreatePromptLink(req, objectFacade, parameter));
            }

            Links = tempLinks.ToArray();
        }
Esempio n. 2
0
        private LinkRepresentation CreatePromptLink(HttpRequest req, IObjectFacade objectFacade, FieldFacadeAdapter parameter)
        {
            var opts = new List <OptionalProperty>();

            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
            {
                var parms     = parameter.GetChoicesParameters();
                var 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(parameter.GetHelper(OidStrategy, req, objectFacade)), Flags, opts.ToArray()));
        }
Esempio n. 3
0
 private static bool IsUnconditionalChoices(FieldFacadeAdapter parameter)
 {
     return(parameter.IsChoicesEnabled != Choices.NotEnabled &&
            (parameter.Specification.IsParseable || (parameter.Specification.IsCollection && parameter.ElementType.IsParseable)) &&
            !parameter.GetChoicesParameters().Any());
 }