Пример #1
0
        public static CdmParameterDefinition FromData(CdmCorpusContext ctx, JToken obj)
        {
            var parameter = ctx.Corpus.MakeObject <CdmParameterDefinition>(CdmObjectType.ParameterDef, (string)obj["name"]);

            parameter.Explanation = (string)obj["explanation"];
            parameter.Required    = obj["required"] != null ? (bool)obj["required"] : false;

            parameter.DefaultValue = Utils.CreateConstant(ctx, obj["defaultValue"]);
            parameter.DataTypeRef  = DataTypeReferencePersistence.FromData(ctx, obj["dataType"]);

            return(parameter);
        }
Пример #2
0
        public static CdmDataTypeDefinition FromData(CdmCorpusContext ctx, JToken obj)
        {
            if (obj == null)
            {
                return(null);
            }
            CdmDataTypeDefinition dataType = ctx.Corpus.MakeObject <CdmDataTypeDefinition>(CdmObjectType.DataTypeDef, (string)obj["dataTypeName"]);

            dataType.ExtendsDataType = DataTypeReferencePersistence.FromData(ctx, obj["extendsDataType"]);

            if (obj["explanation"] != null)
            {
                dataType.Explanation = (string)obj["explanation"];
            }

            Utils.AddListToCdmCollection(dataType.ExhibitsTraits, Utils.CreateTraitReferenceList(ctx, obj["exhibitsTraits"]));
            return(dataType);
        }
Пример #3
0
 /// <summary>
 /// Creates a CDM object from a JSON object
 /// </summary>
 public static dynamic CreateConstant(CdmCorpusContext ctx, dynamic obj)
 {
     if (obj == null)
     {
         return(null);
     }
     if (obj is JValue)
     {
         return(obj.Value);
     }
     else if (obj is JObject)
     {
         if (obj["purpose"] != null || obj["dataType"] != null || obj["entity"] != null)
         {
             if (obj["dataType"] != null)
             {
                 return(TypeAttributePersistence.FromData(ctx, obj));
             }
             else if (obj["entity"] != null)
             {
                 return(EntityAttributePersistence.FromData(ctx, obj));
             }
             else
             {
                 return(null);
             }
         }
         else if (obj["purposeReference"] != null)
         {
             return(PurposeReferencePersistence.FromData(ctx, obj));
         }
         else if (obj["traitReference"] != null)
         {
             return(TraitReferencePersistence.FromData(ctx, obj));
         }
         else if (obj["traitGroupReference"] != null)
         {
             return(TraitGroupReferencePersistence.FromData(ctx, obj));
         }
         else if (obj["dataTypeReference"] != null)
         {
             return(DataTypeReferencePersistence.FromData(ctx, obj));
         }
         else if (obj["entityReference"] != null)
         {
             return(EntityReferencePersistence.FromData(ctx, obj));
         }
         else if (obj["attributeGroupReference"] != null)
         {
             return(AttributeGroupReferencePersistence.FromData(ctx, obj));
         }
         else
         {
             return(obj);
         }
     }
     else
     {
         return(obj);
     }
 }