|
| 1 | +using System; |
| 2 | +using System.Xml; |
| 3 | + |
| 4 | +namespace Sharp.Xmpp.Core |
| 5 | +{ |
| 6 | + /// <summary> |
| 7 | + /// An acknowledgement answer - <a xmlns='urn:xmpp:sm:3' h='1'/> |
| 8 | + /// </summary> |
| 9 | + public class A1 |
| 10 | + { |
| 11 | + private const string @namespace = "urn:xmpp:sm:3"; |
| 12 | + |
| 13 | + /// <summary> |
| 14 | + /// The XmlElement containing the actual data. |
| 15 | + /// </summary> |
| 16 | + protected XmlElement element; |
| 17 | + |
| 18 | + public A1() |
| 19 | + { |
| 20 | + element = Xml.Element(RootElementName, @namespace); |
| 21 | + } |
| 22 | + |
| 23 | + public A1(XmlElement element) |
| 24 | + { |
| 25 | + this.element = element; |
| 26 | + } |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// The sequence Id of the element. |
| 30 | + /// </summary> |
| 31 | + /// <value>The sequence.</value> |
| 32 | + public Int64 Sequence |
| 33 | + { |
| 34 | + get |
| 35 | + { |
| 36 | + var h = element.GetAttribute("h"); |
| 37 | + if (Int64.TryParse(h, out long v)) |
| 38 | + return v; |
| 39 | + else |
| 40 | + return 0; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + /// <summary> |
| 45 | + /// The tag name of the stanza's root element |
| 46 | + /// Allows the element tag name to be overridden. |
| 47 | + /// </summary> |
| 48 | + protected virtual string RootElementName |
| 49 | + { |
| 50 | + get { return GetType().Name.ToLowerInvariant(); } |
| 51 | + } |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// Returns a textual representation of this instance of the class. |
| 55 | + /// </summary> |
| 56 | + /// <returns>A textual representation of this instance.</returns> |
| 57 | + public override string ToString() |
| 58 | + { |
| 59 | + return element.ToXmlString(); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// An acknowledgement request - <r xmlns='urn:xmpp:sm:3'/> |
| 65 | + /// </summary> |
| 66 | + public class R1 |
| 67 | + { |
| 68 | + private const string @namespace = "urn:xmpp:sm:3"; |
| 69 | + |
| 70 | + /// <summary> |
| 71 | + /// The XmlElement containing the actual data. |
| 72 | + /// </summary> |
| 73 | + protected XmlElement element; |
| 74 | + |
| 75 | + public R1() |
| 76 | + { |
| 77 | + element = Xml.Element(RootElementName, @namespace); |
| 78 | + } |
| 79 | + |
| 80 | + public R1(XmlElement element) |
| 81 | + { |
| 82 | + this.element = element; |
| 83 | + } |
| 84 | + |
| 85 | + /// <summary> |
| 86 | + /// The tag name of the stanza's root element |
| 87 | + /// Allows the element tag name to be overridden. |
| 88 | + /// </summary> |
| 89 | + protected virtual string RootElementName |
| 90 | + { |
| 91 | + get { return GetType().Name.ToLowerInvariant(); } |
| 92 | + } |
| 93 | + |
| 94 | + /// <summary> |
| 95 | + /// Returns a textual representation of this instance of the class. |
| 96 | + /// </summary> |
| 97 | + /// <returns>A textual representation of this instance.</returns> |
| 98 | + public override string ToString() |
| 99 | + { |
| 100 | + return element.ToXmlString(); |
| 101 | + } |
| 102 | + } |
| 103 | +} |
0 commit comments