Example #1
0
        private IDictionary <string, object> GetCustomPropertyExtensions()
        {
            if (CustomExtensions == null)
            {
                AddChoicesCustomExtension();

                var mask = PropertyContext.Property.Mask;

                if (!string.IsNullOrWhiteSpace(mask))
                {
                    AddCustomExtension(JsonPropertyNames.CustomMask, mask);
                }

                var multipleLines = PropertyContext.Property.NumberOfLines;

                if (multipleLines > 1)
                {
                    AddCustomExtension(JsonPropertyNames.CustomMultipleLines, multipleLines);
                }

                if (PropertyContext.Property.NotNavigable)
                {
                    AddCustomExtension(JsonPropertyNames.CustomNotNavigable, true);
                }

                if (PropertyContext.Property.IsFindMenuEnabled)
                {
                    AddCustomExtension(JsonPropertyNames.CustomFindMenu, true);
                }

                CustomExtensions = RestUtils.AddRangeExtension(PropertyContext.Property, CustomExtensions);
            }

            return(CustomExtensions);
        }
        private IDictionary <string, object> GetCustomPropertyExtensions()
        {
            if (CustomExtensions == null)
            {
                AddChoicesCustomExtension();

                string mask = PropertyContext.Property.Mask;

                if (!string.IsNullOrWhiteSpace(mask))
                {
                    CustomExtensions = CustomExtensions ?? new Dictionary <string, object>();
                    CustomExtensions[JsonPropertyNames.CustomMask] = mask;
                }

                var multipleLines = PropertyContext.Property.NumberOfLines;

                if (multipleLines > 1)
                {
                    CustomExtensions = CustomExtensions ?? new Dictionary <string, object>();
                    CustomExtensions[JsonPropertyNames.CustomMultipleLines] = multipleLines;
                }

                if (PropertyContext.Property.NotNavigable)
                {
                    CustomExtensions = CustomExtensions ?? new Dictionary <string, object>();
                    CustomExtensions[JsonPropertyNames.CustomNotNavigable] = true;
                }

                CustomExtensions = RestUtils.AddRangeExtension(PropertyContext.Property, CustomExtensions);
            }

            return(CustomExtensions);
        }
Example #3
0
        private void SetExtensions(HttpRequestMessage req, IObjectFacade objectFacade, FieldFacadeAdapter parameter, RestControlFlags flags)
        {
            IDictionary <string, object> custom = null;

            if (IsUnconditionalChoices(parameter))
            {
                custom = new Dictionary <string, object>();

                Tuple <IObjectFacade, string>[] choices      = parameter.GetChoicesAndTitles(objectFacade, null);
                Tuple <object, string>[]        choicesArray = choices.Select(tuple => new Tuple <object, string>(parameter.GetChoiceValue(OidStrategy, req, tuple.Item1, flags), tuple.Item2)).ToArray();

                OptionalProperty[] op  = choicesArray.Select(tuple => new OptionalProperty(tuple.Item2, tuple.Item1)).ToArray();
                MapRepresentation  map = MapRepresentation.Create(op);
                custom[JsonPropertyNames.CustomChoices] = map;
            }

            string mask = parameter.Mask;

            if (!string.IsNullOrWhiteSpace(mask))
            {
                custom = custom ?? new Dictionary <string, object>();
                custom[JsonPropertyNames.CustomMask] = mask;
            }

            var multipleLines = parameter.NumberOfLines;

            if (multipleLines > 1)
            {
                custom = custom ?? new Dictionary <string, object>();
                custom[JsonPropertyNames.CustomMultipleLines] = multipleLines;
            }

            custom = RestUtils.AddRangeExtension(parameter.AsField, custom);

            Extensions = RestUtils.GetExtensions(friendlyname: parameter.Name,
                                                 description: parameter.Description,
                                                 pluralName: null,
                                                 domainType: null,
                                                 isService: null,
                                                 hasParams: null,
                                                 optional: !parameter.IsMandatory,
                                                 maxLength: parameter.MaxLength,
                                                 pattern: parameter.Pattern,
                                                 memberOrder: null,
                                                 dataType: parameter.DataType,
                                                 presentationHint: parameter.PresentationHint,
                                                 customExtensions: custom,
                                                 returnType: parameter.Specification,
                                                 elementType: parameter.ElementType,
                                                 oidStrategy: OidStrategy,
                                                 useDateOverDateTime: true);
        }