public static Contact Read(XmlReader reader) { var result = new Contact(); result.ID = JabberID.Parse(reader.GetAttribute("jid")); reader.Read(); while (reader.NodeType != XmlNodeType.EndElement) { switch (reader.LocalName) { case "username": result.Username = reader.ReadElementContentAsString(); break; case "display-name": result.DisplayName = reader.ReadElementContentAsString(); break; case "pic": result.ProfilePicture = new Uri(reader.ReadElementContentAsString()); break; case "verified": result.Verified = true; reader.Skip(); break; case "pubkey": reader.Skip(); break; default: throw new NotImplementedException(); } } reader.ReadEndElement(); return(result); }
private void HandleGroupStatusUpdate(XmlNode root, JabberID from, JabberID group, XmlNode statusNode) { string message = statusNode.InnerText; if (message.EndsWith("has joined the chat")) { HandleMemberJoined(group, JabberID.Parse(statusNode.Attributes["jid"].InnerText)); } else if (message.EndsWith("has left the chat")) { HandleMemberLeft(group, JabberID.Parse(statusNode.Attributes["jid"].InnerText)); } }
public static Group Read(XmlReader reader) { var result = new Group(); result.IsPublic = bool.Parse(reader.GetAttribute("is-public")); result.ID = JabberID.Parse(reader.GetAttribute("jid")); reader.Read(); while (reader.NodeType != XmlNodeType.EndElement) { switch (reader.LocalName) { case "code": result.Hashtag = reader.ReadElementContentAsString(); break; case "n": result.Name = reader.ReadElementContentAsString(); break; case "pic": result.ProfilePicture = new Uri(reader.ReadElementContentAsString()); break; case "m": var role = Role.Member; if (reader.GetAttribute("s") == "1") { role = Role.SuperAdmin; } else if (reader.GetAttribute("a") == "1") { role = Role.Admin; } var member_jid = JabberID.Parse(reader.ReadElementContentAsString()); result.Members.Add(member_jid, role); break; case "b": var banned_jid = JabberID.Parse(reader.ReadElementContentAsString()); result.Members.Add(banned_jid, Role.Banned); break; default: throw new NotImplementedException(); } } reader.ReadEndElement(); return(result); }