What is the simplest and elegant way to parse JSON with Json.Net and check if it is subtype? Here is an example.
Shared class library:
public abstract class State {}
public class PlayerState : State {}
public class VehicleState : State {}
Server-side:
var _state = Utils.GetStateFromString<State>(s);
if (_state is PlayerState) {
PlayerState state = (PlayerState) _state;
...
}
else if (_state is VehicleState) {
VehicleState state = (VehicleState) _state;
...
}
where s is serialized string from client.
I get it's works only using TypeNameHandling = TypeNameHandling.Objects
and creating custom SerializationBinder, but it is very hart to add all types to binder, because of there are different assemblies on client and server.
I know about JsonSubType lib, but my platform doesn't allow adding links in project