Ejemplo n.º 1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jObject = JObject.Load(reader);

            var typeId = Convert.ToByte(jObject.Property("Type").Value.ToString());
            var type   = (EditTypes)typeId;

            object target = null;

            switch (type)
            {
            case EditTypes.Textbox:
                target = new Textbox();
                break;

            case EditTypes.Numberbox:
                target = new Numberbox();
                break;

            case EditTypes.Datepicker:
                target = new Datepicker();
                break;

            case EditTypes.Enumlist:
                target = new Enumlist();
                break;

            case EditTypes.Selectlist:
                target = new Selectlist();
                break;

            case EditTypes.FileUpload:
                target = new FileUpload();
                break;

            case EditTypes.Autocomplete:
                target = new Autocomplete();
                break;

            case EditTypes.Htmlbox:
                target = new Htmlbox();
                break;

            default:
                target = new EditField();
                break;
            }

            serializer.Populate(jObject.CreateReader(), target);
            return(target);
        }
Ejemplo n.º 2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JObject jObject = JObject.Load(reader);

            var typeId = Convert.ToByte(jObject.Property("Type").Value.ToString());
            var type = (EditTypes)typeId;

            object target = null;
            switch (type)
            {
                case EditTypes.Textbox:
                    target = new Textbox();
                    break;
                case EditTypes.Numberbox:
                    target = new Numberbox();
                    break;
                case EditTypes.Datepicker:
                    target = new Datepicker();
                    break;
                case EditTypes.Enumlist:
                    target = new Enumlist();
                    break;
                case EditTypes.Selectlist:
                    target = new Selectlist();
                    break;
                case EditTypes.FileUpload:
                    target = new FileUpload();
                    break;
                case EditTypes.Autocomplete:
                    target = new Autocomplete();
                    break;
                case EditTypes.Htmlbox:
                    target = new Htmlbox();
                    break;
                default:
                    target = new EditField();
                    break;
            }

            serializer.Populate(jObject.CreateReader(), target);
            return target;
        }