Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UserAvatar.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Xml;
5using Waher.Content;
8
10{
16 {
17 private byte[] data = null;
18 private string sha1Hash = null;
19
24 public UserAvatar()
25 {
26 }
27
31 public override string LocalName => "data";
32
36 public override string Namespace => "urn:xmpp:avatar:data";
37
41 public override string PayloadXml
42 {
43 get
44 {
45 StringBuilder Xml = new StringBuilder();
46
47 Xml.Append("<data xmlns='");
48 Xml.Append(this.Namespace);
49 Xml.Append("'>");
50 Xml.Append(Convert.ToBase64String(this.data));
51 Xml.Append("</data>");
52
53 return Xml.ToString();
54 }
55 }
56
60 public override string ItemId
61 {
62 get
63 {
64 if (this.sha1Hash is null)
65 this.sha1Hash = Hashes.ComputeSHA1HashString(this.data);
66
67 return this.sha1Hash;
68 }
69 }
70
76 public override IPersonalEvent Parse(XmlElement E)
77 {
78 UserAvatar Result = new UserAvatar()
79 {
80 data = Convert.FromBase64String(E.InnerText)
81 };
82
83 return Result;
84 }
85
89 public byte[] Data
90 {
91 get => this.data;
92 set
93 {
94 this.data = value;
95 this.sha1Hash = null;
96 }
97 }
98
99 }
100}
User Avatar event, as defined in XEP-0084: https://xmpp.org/extensions/xep-0084.html
Definition: UserAvatar.cs:16
override string LocalName
Local name of the event element.
Definition: UserAvatar.cs:31
override string ItemId
Optional Item ID of event. If null, a new will automatically be generated by the server.
Definition: UserAvatar.cs:61
byte[] Data
Binary representation of avatar
Definition: UserAvatar.cs:90
override IPersonalEvent Parse(XmlElement E)
Parses a personal event from its XML representation
Definition: UserAvatar.cs:76
UserAvatar()
User Avatar event, as defined in XEP-0084: https://xmpp.org/extensions/xep-0084.html
Definition: UserAvatar.cs:24
override string PayloadXml
XML representation of the event.
Definition: UserAvatar.cs:42
override string Namespace
Namespace of the event element.
Definition: UserAvatar.cs:36
Contains methods for simple hash calculations.
Definition: Hashes.cs:59
static string ComputeSHA1HashString(byte[] Data)
Computes the SHA-1 hash of a block of binary data.
Definition: Hashes.cs:274
Interface for personal event objects.