示例#1
0
 private void SetScalars(INakedObjectSpecificationSurface spec) {
     Name = spec.FullName();
     DomainType = spec.DomainTypeName();
     FriendlyName = spec.SingularName();
     PluralName = spec.PluralName();
     Description = spec.Description();
     IsService = spec.IsService();
 }
示例#2
0
 private void SetScalars(INakedObjectSpecificationSurface spec)
 {
     Name         = spec.FullName();
     DomainType   = spec.DomainTypeName();
     FriendlyName = spec.SingularName();
     PluralName   = spec.PluralName();
     Description  = spec.Description();
     IsService    = spec.IsService();
 }
示例#3
0
        public static MapRepresentation GetExtensions(string friendlyname,
                                                      string description,
                                                      string pluralName,
                                                      string domainType,
                                                      bool?isService,
                                                      bool?hasParams,
                                                      bool?optional,
                                                      int?maxLength,
                                                      string pattern,
                                                      int?memberOrder,
                                                      IDictionary <string, object> customExtensions,
                                                      INakedObjectSpecificationSurface returnType,
                                                      INakedObjectSpecificationSurface elementType)
        {
            var exts = new Dictionary <string, object> {
                { JsonPropertyNames.FriendlyName, friendlyname },
                { JsonPropertyNames.Description, description }
            };

            if (pluralName != null)
            {
                exts.Add(JsonPropertyNames.PluralName, pluralName);
            }

            if (domainType != null)
            {
                exts.Add(JsonPropertyNames.DomainType, domainType);
            }

            if (hasParams != null)
            {
                exts.Add(JsonPropertyNames.HasParams, hasParams);
            }

            if (isService != null)
            {
                exts.Add(JsonPropertyNames.IsService, isService);
            }

            if (optional != null)
            {
                exts.Add(JsonPropertyNames.Optional, optional);
            }

            if (memberOrder != null)
            {
                exts.Add(JsonPropertyNames.MemberOrder, memberOrder);
            }

            if (returnType != null && !returnType.IsVoid())
            {
                Tuple <string, string> jsonDataType = SpecToTypeAndFormatString(returnType);
                exts.Add(JsonPropertyNames.ReturnType, jsonDataType.Item1);

                // blob and clobs are arrays so do this check first so they are not caught be the collection test after.
                if (jsonDataType.Item1 == PredefinedType.Number.ToRoString())
                {
                    exts.Add(JsonPropertyNames.Format, jsonDataType.Item2);
                }
                else if (jsonDataType.Item1 == PredefinedType.String.ToRoString())
                {
                    exts.Add(JsonPropertyNames.Format, jsonDataType.Item2);
                    exts.Add(JsonPropertyNames.MaxLength, maxLength ?? 0);
                    exts.Add(JsonPropertyNames.Pattern, pattern ?? "");
                }
                else if (returnType.IsCollection())
                {
                    exts.Add(JsonPropertyNames.ElementType, SpecToTypeAndFormatString(elementType).Item1);
                    exts.Add(JsonPropertyNames.PluralName, elementType.PluralName());
                }
            }

            if (customExtensions != null)
            {
                foreach (var kvp in customExtensions)
                {
                    exts.Add(kvp.Key, kvp.Value);
                }
            }

            return(CreateMap(exts));
        }