public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var jsonObject = JObject.Load(reader); var WidgetState = default(IWidgetState); string objectTypeName = jsonObject["TypeName"].Value <string>(); if (objectTypeName == typeof(BlankWidgetState).Name) { WidgetState = new BlankWidgetState(); } else if (objectTypeName == typeof(OxyPlotWidgetState).Name) { WidgetState = new OxyPlotWidgetState(); } else if (objectTypeName == typeof(DataExportWidgetState).Name) { WidgetState = new DataExportWidgetState(); } if (WidgetState != null) { serializer.Populate(jsonObject.CreateReader(), WidgetState); } return(WidgetState); }
public IWidgetState GenerateState() { BlankWidgetState state = new BlankWidgetState(); // currently nothing is stored in the state return(state); }