/// <summary> /// Construct an instance from the specified tagged JSONReader stream. /// </summary> /// <param name="JSONReader">Input stream</param> /// <param name="Out">The created object</param> public static void Deserialize(JSONReader JSONReader, out JSONObject Out) { JSONReader.StartObject (); if (JSONReader.EOR) { Out = null; return; } string token = JSONReader.ReadToken (); Out = null; switch (token) { case "SSHProfile" : { var Result = new SSHProfile (); Result.Deserialize (JSONReader); Out = Result; break; } case "SSHProfilePrivate" : { var Result = new SSHProfilePrivate (); Result.Deserialize (JSONReader); Out = Result; break; } case "DeviceEntry" : { var Result = new DeviceEntry (); Result.Deserialize (JSONReader); Out = Result; break; } case "HostEntry" : { var Result = new HostEntry (); Result.Deserialize (JSONReader); Out = Result; break; } default : { throw new Exception ("Not supported"); } } JSONReader.EndObject (); }
/// <summary> /// Deserialize a tagged stream /// </summary> /// <param name="JSONReader">The input stream</param> /// <returns>The created object.</returns> public static new HostEntry FromTagged (JSONReader JSONReader) { HostEntry Out = null; JSONReader.StartObject (); if (JSONReader.EOR) { return null; } string token = JSONReader.ReadToken (); switch (token) { case "HostEntry" : { var Result = new HostEntry (); Result.Deserialize (JSONReader); Out = Result; break; } default : { //Ignore the unknown data //throw new Exception ("Not supported"); break; } } JSONReader.EndObject (); return Out; }
/// <summary> /// Having read a tag, process the corresponding value data. /// </summary> /// <param name="JSONReader">The input stream</param> /// <param name="Tag">The tag</param> public override void DeserializeToken (JSONReader JSONReader, string Tag) { switch (Tag) { case "Account" : { Account = JSONReader.ReadString (); break; } case "DeviceEntries" : { // Have a sequence of values bool _Going = JSONReader.StartArray (); DeviceEntries = new List <DeviceEntry> (); while (_Going) { // an untagged structure. var _Item = new DeviceEntry (JSONReader); DeviceEntries.Add (_Item); _Going = JSONReader.NextArray (); } break; } case "HostEntries" : { // Have a sequence of values bool _Going = JSONReader.StartArray (); HostEntries = new List <HostEntry> (); while (_Going) { // an untagged structure. var _Item = new HostEntry (JSONReader); HostEntries.Add (_Item); _Going = JSONReader.NextArray (); } break; } default : { base.DeserializeToken(JSONReader, Tag); break; } } // check up that all the required elements are present }