public override object FromRawState(TextState raw) { try { var stateType = StoredTypes.ForName(raw.Type); return(JsonSerialization.Deserialized(raw.Data, stateType) !); } catch (Exception e) { throw new InvalidOperationException($"Cannot convert to type: {raw.Type}", e); } }
public override TState FromEntry(TextEntry entry) { try { var sourceType = StoredTypes.ForName(entry.TypeName); var bland = JsonSerialization.Deserialized(entry.EntryData, sourceType); return((TState)bland !); } catch (Exception) { throw new InvalidOperationException($"Cannot convert to type: {entry.TypeName}"); } }
public static IEnumerable <IEntry <T> > None => new IEntry <T> [0]; // Enumerable.Empty<IEntry<T>>(); throws an exception on deserialization with Netwtonsoft public static Type TypedFrom(string type) => StoredTypes.ForName(type) !;