/// <summary> /// Add an entry to the profile. /// </summary> /// <param name="Site">Site at which this entry is to be used.</param> /// <param name="Username">Username</param> /// <param name="Password">Password</param> public void Add(string Site, string Username, string Password) { Delete(Site); var Entry = new PasswordEntry(Site, Username, Password); Entries = Entries == null ? new List<PasswordEntry> (): Entries; Entries.Add (Entry); }
/// <summary> /// Deserialize a tagged stream /// </summary> /// <param name="JSONReader">The input stream</param> /// <returns>The created object.</returns> public static new PasswordEntry FromTagged (JSONReader JSONReader) { PasswordEntry Out = null; JSONReader.StartObject (); if (JSONReader.EOR) { return null; } string token = JSONReader.ReadToken (); switch (token) { case "PasswordEntry" : { var Result = new PasswordEntry (); Result.Deserialize (JSONReader); Out = Result; break; } default : { //Ignore the unknown data //throw new Exception ("Not supported"); break; } } JSONReader.EndObject (); return Out; }
/// <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 "PasswordProfile" : { var Result = new PasswordProfile (); Result.Deserialize (JSONReader); Out = Result; break; } case "PasswordProfilePrivate" : { var Result = new PasswordProfilePrivate (); Result.Deserialize (JSONReader); Out = Result; break; } case "PasswordEntry" : { var Result = new PasswordEntry (); Result.Deserialize (JSONReader); Out = Result; break; } default : { throw new Exception ("Not supported"); } } JSONReader.EndObject (); }
/// <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 "AutoGenerate" : { AutoGenerate = JSONReader.ReadBoolean (); break; } case "Entries" : { // Have a sequence of values bool _Going = JSONReader.StartArray (); Entries = new List <PasswordEntry> (); while (_Going) { // an untagged structure. var _Item = new PasswordEntry (JSONReader); Entries.Add (_Item); _Going = JSONReader.NextArray (); } break; } case "NeverAsk" : { // Have a sequence of values bool _Going = JSONReader.StartArray (); NeverAsk = new List <string> (); while (_Going) { string _Item = JSONReader.ReadString (); NeverAsk.Add (_Item); _Going = JSONReader.NextArray (); } break; } default : { break; } } // check up that all the required elements are present }