Beispiel #1
0
 public void AddLov(Lov lov)
 {
     lov.ParentEntity = this.parentEntity;
     lovs.Add(lov);
 }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null)
            {
                return(null);
            }

            JObject      jObject = JObject.Load(reader);
            ViewFieldLov target  = default(ViewFieldLov);

            if (jObject != null)
            {
                target = Create(objectType);
                if (jObject["DependantProperty"].HasValues)
                {
                    target.DependantProperty = jObject["DependantProperty"]["$ref"].Value <string>();
                }
                if (jObject["DependantViewFieldLOV"].HasValues)
                {
                    target.DependantViewFieldLOV = jObject["DependantViewFieldLOV"]["$ref"].Value <string>();
                }
                if (jObject["DisplayProperty"].HasValues)
                {
                    target.DisplayProperty = jObject["DisplayProperty"]["$ref"].Value <string>();
                }
                if (jObject["EntityInternal"].HasValues)
                {
                    target.EntityInternal = jObject["EntityInternal"]["$ref"].Value <string>();
                }

                if (jObject["InLineLink"].HasValues)
                {
                    Link obj = jObject["InLineLink"].ToObject <Link>(serializer);
                    if (obj != null)
                    {
                        target.AddInLineLink(obj);
                    }
                }

                if (jObject["LovsInternal"]["$values"].HasValues)
                {
                    foreach (var flchild in jObject["LovsInternal"]["$values"])
                    {
                        Lov obj = flchild.ToObject <Lov>(serializer);
                        if (obj != null)
                        {
                            target.AddLov(obj);
                        }
                    }
                }

                target.OrderLovType = (OrderLovType)Enum.Parse(typeof(OrderLovType), jObject["OrderLovType"].Value <string>());
                target.RowLimit     = jObject["RowLimit"].Value <int>();

                if (jObject["ShowPropertiesInternal"]["$values"].HasValues)
                {
                    foreach (var flchild in jObject["ShowPropertiesInternal"]["$values"])
                    {
                        var obj = flchild["$ref"].Value <string>();
                        if (obj != null)
                        {
                            target.ShowPropertiesInternal.Add(Guid.Parse(obj));
                        }
                    }
                }

                target.SqlOrderBy = jObject["SqlOrderBy"].Value <string>();
                target.SqlWhere   = jObject["SqlWhere"].Value <string>();
                target.SqlWhere   = jObject["SqlWhere"].Value <string>();

                if (jObject["ValueProperty"].HasValues)
                {
                    target.ValueProperty = jObject["ValueProperty"]["$ref"].Value <string>();
                }
            }
            return(target);
        }