public static void Deserialize(string _Input, out QueryConnectResponse Out) { StringReader _Reader = new StringReader (_Input); JSONReader JSONReader = new JSONReader (_Reader); JSONReader.StartObject (); string token = JSONReader.ReadToken (); Out = null; switch (token) { case "QueryConnectResponse" : { QueryConnectResponse Result = new QueryConnectResponse (); Result.Deserialize (JSONReader); Out = Result; break; } default : { throw new Exception ("Not supported"); } } JSONReader.EndObject (); // should we check for EOF here? }
public override QResponse Dispatch(QueryServerContext Context, TicketData TicketData) { QueryConnectResponse Response = new QueryConnectResponse(); // If we were doing this properly we would do a DNS lookup // (via a cache of course) to resolve the parameters here Response.Connection = new List<Connection> (); Response.Connection.Add (new Connection ( "10.3.2.1", 443, "TLS", "TLS=Optional", "Strict")); Response.Connection.Add (new Connection ("10.3.2.1", 80, null, null, "Strict")); Response.Status = 200; return Response; }
public static void Deserialize(string _Input, out QResponse Out) { StringReader _Reader = new StringReader (_Input); JSONReader JSONReader = new JSONReader (_Reader); JSONReader.StartObject (); string token = JSONReader.ReadToken (); Out = null; switch (token) { case "QResponse" : { Out = null; throw new Exception ("Can't create abstract type"); } case "QueryConnectResponse" : { QueryConnectResponse Result = new QueryConnectResponse (); Result.Deserialize (JSONReader); Out = Result; break; } case "AdvertiseResponse" : { AdvertiseResponse Result = new AdvertiseResponse (); Result.Deserialize (JSONReader); Out = Result; break; } case "ValidateResponse" : { ValidateResponse Result = new ValidateResponse (); Result.Deserialize (JSONReader); Out = Result; break; } case "CredentialPasswordResponse" : { CredentialPasswordResponse Result = new CredentialPasswordResponse (); Result.Deserialize (JSONReader); Out = Result; break; } default : { throw new Exception ("Not supported"); } } JSONReader.EndObject (); // should we check for EOF here? }