Exemplo n.º 1
0
        private void ReadArrary(DynamicData dynamic, JArray jobject)
        {
            foreach (var item in jobject.Children())
            {
                switch (item.Type)
                {
                case JTokenType.Array:
                    var t = new DynamicJson();
                    this.ReadArrary(t, (JArray)item);
                    dynamic.Set(item.Path, t);
                    break;

                case JTokenType.Boolean:
                    dynamic.Set(item.Path, (bool)item.Value <bool>());
                    break;

                case JTokenType.Float:
                    dynamic.Set(item.Path, item.Value <float>());
                    break;

                case JTokenType.Bytes:
                    dynamic.Set(item.Path, item.Value <byte[]>());
                    break;

                case JTokenType.Constructor:
                    dynamic.Set(item.Path, item.Value <string>());
                    break;

                case JTokenType.Date:
                    dynamic.Set(item.Path, item.Value <DateTime>());
                    break;

                case JTokenType.Guid:
                    dynamic.Set(item.Path, item.Value <Guid>());
                    break;

                case JTokenType.Integer:
                    dynamic.Set(item.Path, (int)item.Value <int>());
                    break;

                case JTokenType.Null:
                    dynamic.Set(item.Path, null);
                    break;

                case JTokenType.String:
                    dynamic.Set(item.Path, item.Value <string>());
                    break;

                case JTokenType.TimeSpan:
                    dynamic.Set(item.Path, item.Value <TimeSpan>());
                    break;

                case JTokenType.Undefined:
                    break;

                case JTokenType.Uri:
                    dynamic.Set(item.Path, item.Value <Uri>());
                    break;

                case JTokenType.Raw:
                    var temp = new DynamicJson();
                    temp.Deserialize(item.Value <string>());
                    dynamic.Set(item.Path, temp);
                    break;

                case JTokenType.Object:
                    var temp1 = new DynamicJson();
                    this.ReadProperties(temp1, item.Value <JObject>());
                    dynamic.Set(item.Path, temp1);
                    break;

                case JTokenType.Property:
                    dynamic.Set(item.Path, item.Value <object>());
                    break;

                default: break;
                }
            }
        }
Exemplo n.º 2
0
 public Message()
 {
     Data = new DynamicJson();
 }