예제 #1
0
        /// <summary>
        /// Converts a JSON object to an Attribute object
        /// </summary>
        public static CdmAttributeItem CreateAttribute(CdmCorpusContext ctx, dynamic obj, string entityName = null)
        {
            if (obj == null)
            {
                return(null);
            }

            if (obj is JValue)
            {
                return(AttributeGroupReferencePersistence.FromData(ctx, obj));
            }
            else
            {
                if (obj["attributeGroupReference"] != null)
                {
                    return(AttributeGroupReferencePersistence.FromData(ctx, obj, entityName));
                }
                else if (obj["entity"] != null)
                {
                    return(EntityAttributePersistence.FromData(ctx, obj));
                }
                else if (obj["name"] != null)
                {
                    return(TypeAttributePersistence.FromData(ctx, obj, entityName));
                }
            }
            return(null);
        }
예제 #2
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["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);
     }
 }