Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
FriendshipRule.cs
1using System;
2using System.Text;
3using System.Xml;
4using Waher.Content;
8
10{
14 [CollectionName("FriendshipRules")]
15 [TypeName(TypeNameSerialization.None)]
16 [ArchivingTime]
17 [Index("JID", "RemoteJID")]
18 public class FriendshipRule
19 {
20 private Guid objectId = Guid.Empty;
23 private bool canSubscribeToPresence = false;
24
29 {
30 }
31
35 [ObjectId]
36 public Guid ObjectId
37 {
38 get => this.objectId;
39 set => this.objectId = value;
40 }
41
46 {
47 get => this.jid;
48 set => this.jid = value;
49 }
50
55 {
56 get => this.remoteJid;
57 set => this.remoteJid = value;
58 }
59
63 [DefaultValue(false)]
65 {
66 get => this.canSubscribeToPresence;
67 set => this.canSubscribeToPresence = value;
68 }
69
74 public void Export(XmlWriter Output)
75 {
76 Output.WriteStartElement("FriendshipRule", Rule.RuleNamespace);
77 Output.WriteAttributeString("jid", this.jid);
78 Output.WriteAttributeString("remoteJid", this.remoteJid);
79 Output.WriteAttributeString("canSubscribeToPresence", CommonTypes.Encode(this.canSubscribeToPresence));
80 Output.WriteEndElement();
81 }
82
87 public string ExportXml()
88 {
89 StringBuilder sb = new StringBuilder();
90
91 using (XmlWriter w = XmlWriter.Create(sb))
92 {
93 this.Export(w);
94 }
95
96 return sb.ToString();
97 }
98 }
99}
Helps with parsing of commong data types.
Definition: CommonTypes.cs:13
static string Encode(bool x)
Encodes a Boolean for use in XML and other formats.
Definition: CommonTypes.cs:594
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
Controls if a device with a remote JID is allowed to subscribe to the presence of a device with JID.
string ExportXml()
Exports the rule as an XML string.
FriendshipRule()
Controls if a device with a remote JID is allowed to subscribe to the presence of a device with JID.
void Export(XmlWriter Output)
Exports the rule.
CaseInsensitiveString RemoteJID
JID of device that want to subscribe to presence.
bool CanSubscribeToPresence
If presence subscription should be permitted.
CaseInsensitiveString JID
JID of device needing to decide if a presence subscription should be accepted or rejected.
Abstract base class for rules.
Definition: Rule.cs:12
const string RuleNamespace
http://waher.se/Schema/Provisioning/Rules.xsd
Definition: Rule.cs:16
TypeNameSerialization
How the type name should be serialized.