Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
XmppAddress.cs
2
4{
8 public class XmppAddress
9 {
10 private readonly CaseInsensitiveString address;
11 private CaseInsensitiveString bareJid = null;
12 private CaseInsensitiveString domain = null;
13 private CaseInsensitiveString account = null;
14 private CaseInsensitiveString resource = null;
15
21 {
22 if (Address?.Value is null)
23 this.address = CaseInsensitiveString.Empty;
24 else
25 this.address = Address;
26 }
27
32
37 {
38 get => this.address;
39 }
40
45 {
46 get
47 {
48 if ((object)this.bareJid is null)
49 {
50 int i = this.address.IndexOf('/');
51 if (i < 0)
52 {
53 this.bareJid = this.address;
54 this.resource = CaseInsensitiveString.Empty;
55 }
56 else
57 {
58 this.bareJid = this.address.Substring(0, i);
59 this.resource = this.address.Substring(i + 1);
60 }
61 }
62
63 return this.bareJid;
64 }
65 }
66
71 {
72 get
73 {
74 if ((object)this.resource is null)
75 {
76 int i = this.address.IndexOf('/');
77 if (i < 0)
78 {
79 this.bareJid = this.address;
80 this.resource = CaseInsensitiveString.Empty;
81 }
82 else
83 {
84 this.bareJid = this.address.Substring(0, i);
85 this.resource = this.address.Substring(i + 1);
86 }
87 }
88
89 return this.resource;
90 }
91 }
92
97 {
98 get
99 {
100 if ((object)this.domain is null)
101 {
103 int i = s.IndexOf('@');
104 if (i < 0)
105 {
106 this.domain = s;
107 this.account = CaseInsensitiveString.Empty;
108 }
109 else
110 {
111 this.account = s.Substring(0, i);
112 this.domain = s.Substring(i + 1);
113 }
114 }
115
116 return this.domain;
117 }
118 }
119
124 {
125 get
126 {
127 if ((object)this.account is null)
128 {
130 int i = s.IndexOf('@');
131 if (i < 0)
132 {
133 this.domain = s;
134 this.account = CaseInsensitiveString.Empty;
135 }
136 else
137 {
138 this.account = s.Substring(0, i);
139 this.domain = s.Substring(i + 1);
140 }
141 }
142
143 return this.account;
144 }
145 }
146
150 public bool IsFullJID
151 {
152 get { return !CaseInsensitiveString.IsNullOrEmpty(this.Resource); }
153 }
154
158 public bool IsBareJID
159 {
160 get { return CaseInsensitiveString.IsNullOrEmpty(this.Resource); }
161 }
162
166 public bool HasAccount
167 {
168 get { return !CaseInsensitiveString.IsNullOrEmpty(this.Account); }
169 }
170
174 public bool IsDomain
175 {
177 }
178
182 public bool IsEmpty
183 {
184 get { return CaseInsensitiveString.IsNullOrEmpty(this.address); }
185 }
186
190 public override string ToString()
191 {
192 return this.address.Value;
193 }
194
198 public override bool Equals(object obj)
199 {
200 return obj is XmppAddress Addr && this.address == Addr.address;
201 }
202
206 public override int GetHashCode()
207 {
208 return this.address.GetHashCode();
209 }
210
216 {
217 if (this.IsBareJID)
218 return this;
219 else
220 return new XmppAddress(this.BareJid);
221 }
222
223 }
224}
Contains information about one XMPP address.
Definition: XmppAddress.cs:9
override string ToString()
object.ToString()
Definition: XmppAddress.cs:190
bool IsBareJID
If the address is a Bare JID.
Definition: XmppAddress.cs:159
XmppAddress(CaseInsensitiveString Address)
Contains information about one XMPP address.
Definition: XmppAddress.cs:20
bool HasAccount
If the address has an account part.
Definition: XmppAddress.cs:167
override bool Equals(object obj)
object.Equals(object)
Definition: XmppAddress.cs:198
bool IsEmpty
If the address is empty.
Definition: XmppAddress.cs:183
CaseInsensitiveString Resource
Resource part.
Definition: XmppAddress.cs:71
CaseInsensitiveString Domain
Domain
Definition: XmppAddress.cs:97
CaseInsensitiveString Address
XMPP Address
Definition: XmppAddress.cs:37
bool IsDomain
If the Address is a domain.
Definition: XmppAddress.cs:175
XmppAddress ToBareJID()
Returns the Bare JID as an XmppAddress object.
Definition: XmppAddress.cs:215
CaseInsensitiveString BareJid
Bare JID
Definition: XmppAddress.cs:45
static readonly XmppAddress Empty
Empty address.
Definition: XmppAddress.cs:31
override int GetHashCode()
object.GetHashCode()
Definition: XmppAddress.cs:206
CaseInsensitiveString Account
Account
Definition: XmppAddress.cs:124
bool IsFullJID
If the Address is a Full JID.
Definition: XmppAddress.cs:151
Represents a case-insensitive string.
static readonly CaseInsensitiveString Empty
Empty case-insensitive string
int IndexOf(CaseInsensitiveString value, StringComparison comparisonType)
Reports the zero-based index of the first occurrence of the specified string in the current System....
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
CaseInsensitiveString Substring(int startIndex, int length)
Retrieves a substring from this instance. The substring starts at a specified character position and ...