2using System.Globalization;
15 [CollectionName(
"ContactInformation")]
17 [Index(
"BareJid",
"SourceId",
"Partition",
"NodeId")]
18 [Index(
"IsThing",
"BareJid",
"SourceId",
"Partition",
"NodeId")]
22 private string? objectId =
null;
27 private string friendlyName =
string.Empty;
28 private string sourceId =
string.Empty;
29 private string partition =
string.Empty;
30 private string nodeId =
string.Empty;
32 private bool? subscribeTo =
null;
33 private bool? allowSubscriptionFrom =
null;
34 private bool? isThing =
null;
35 private bool? isSensor =
null;
36 private bool? isActuator =
null;
37 private bool? isConcentrator =
null;
38 private bool? supportsSensorEvents =
null;
39 private bool? owner =
null;
55 set => this.objectId = value;
64 set => this.bareJid = value;
73 set => this.legalId = value;
82 get => this.legalIdentity;
83 set => this.legalIdentity = value;
89 [DefaultValueStringEmpty]
92 get => this.friendlyName;
93 set => this.friendlyName = value;
101 get => this.sourceId;
102 set => this.sourceId = value;
110 get => this.partition;
111 set => this.partition = value;
120 set => this.nodeId = value;
128 get => this.registryJid;
129 set => this.registryJid = value;
137 get => this.subscribeTo;
138 set => this.subscribeTo = value;
146 get => this.allowSubscriptionFrom;
147 set => this.allowSubscriptionFrom = value;
156 set => this.isThing = value;
164 get => this.isSensor;
165 set => this.isSensor = value;
173 get => this.supportsSensorEvents;
174 set => this.supportsSensorEvents = value;
182 get => this.isActuator;
183 set => this.isActuator = value;
191 get => this.isConcentrator;
192 set => this.isConcentrator = value;
202 set => this.owner = value;
211 get => this.metaData;
212 set => this.metaData = value;
267 string Account = RemoteId.
Substring(0, i);
271 if (AccountIsGuid = Guid.TryParse(Account, out Guid _))
283 if (Info is not
null)
295 if (!
string.IsNullOrEmpty(s))
301 if (Item is not
null)
305 if (identityCache.TryGetValue(RemoteId, out
LegalIdentity? Id))
309 AccountIsGuid =
false;
314 identityCache[RemoteId] =
null;
316 Task _ = Task.Run(async () =>
323 identityCache[RemoteId] = Id;
335 private static readonly Dictionary<CaseInsensitiveString, LegalIdentity?> identityCache = [];
344 if (RemoteId is
null)
347 int i, c = RemoteId.Length;
348 string[] Result =
new string[c];
350 for (i = 0; i < c; i++)
363 string? Apartment =
null;
365 string? Building =
null;
367 string? Class =
null;
368 string? Country =
null;
369 string? Manufacturer =
null;
370 string? MeterLocation =
null;
371 string? MeterNumber =
null;
372 string? Model =
null;
374 string? Region =
null;
376 string? SerialNumber =
null;
377 string? Street =
null;
378 string? StreetNumber =
null;
379 string? Version =
null;
380 string? Phone =
null;
383 switch (P.
Name.ToUpper(CultureInfo.InvariantCulture))
418 StreetNumber = P.
Value;
426 Manufacturer = P.
Value;
430 MeterLocation = P.
Value;
434 MeterNumber = P.
Value;
446 SerialNumber = P.
Value;
458 StringBuilder? sb =
null;
460 AppendName(ref sb, Class);
461 AppendName(ref sb, Model);
462 AppendName(ref sb, Version);
463 AppendName(ref sb, Room);
464 AppendName(ref sb, Name);
465 AppendName(ref sb, Apartment);
466 AppendName(ref sb, Building);
467 AppendName(ref sb, Street);
468 AppendName(ref sb, StreetNumber);
469 AppendName(ref sb, Area);
470 AppendName(ref sb, City);
471 AppendName(ref sb, Region);
472 AppendName(ref sb, Country);
473 AppendName(ref sb, MeterNumber);
474 AppendName(ref sb, MeterLocation);
475 AppendName(ref sb, Manufacturer);
476 AppendName(ref sb, SerialNumber);
477 AppendName(ref sb, Phone);
479 return sb?.ToString();
489 if (Identity is
null)
492 string? FirstName =
null;
493 string? MiddleName =
null;
494 string? LastName =
null;
495 string? PersonalNumber =
null;
496 string? Domain =
null;
497 string? OrgDepartment =
null;
498 string? OrgRole =
null;
499 string? OrgName =
null;
500 bool HasName =
false;
502 bool HasDomain =
false;
504 foreach (
Property P
in Identity.Properties)
506 switch (P.
Name.ToUpper(CultureInfo.InvariantCulture))
514 MiddleName = P.
Value;
524 PersonalNumber = P.
Value;
533 OrgDepartment = P.
Value;
549 StringBuilder? sb =
null;
553 AppendName(ref sb, FirstName);
554 AppendName(ref sb, MiddleName);
555 AppendName(ref sb, LastName);
560 AppendName(ref sb, OrgRole);
561 AppendName(ref sb, OrgDepartment);
562 AppendName(ref sb, OrgName);
565 string Result = sb is not
null ? sb.ToString() : !
string.IsNullOrEmpty(PersonalNumber) ? PersonalNumber : Identity.Id;
568 Result = Domain +
" (" + Result +
")";
579 string? FirstName =
null;
580 string? MiddleNames =
null;
581 string? LastNames =
null;
583 if (Identity?.Properties is not
null)
584 foreach (
Property P
in Identity.Properties)
596 MiddleNames = P.
Value;
600 return GetFullName(FirstName, MiddleNames, LastNames);
609 public static string GetFullName(
string? FirstName,
string? MiddleNames,
string? LastNames)
611 StringBuilder? sb =
null;
613 AppendName(ref sb, FirstName);
614 AppendName(ref sb, MiddleNames);
615 AppendName(ref sb, LastNames);
617 return sb?.ToString() ??
string.Empty;
625 internal static void AppendName(ref StringBuilder? sb,
string? Value)
627 if (!
string.IsNullOrEmpty(Value))
630 sb =
new StringBuilder();
648 if (
string.IsNullOrEmpty(
NodeId) &&
string.IsNullOrEmpty(PartitionId) &&
string.IsNullOrEmpty(
SourceId))
653 if (Thing is not
null)
658 if (!
string.IsNullOrEmpty(PartitionId))
659 if (
string.IsNullOrEmpty(s))
664 if (!
string.IsNullOrEmpty(
SourceId))
665 if (
string.IsNullOrEmpty(s))
678 public string this[
string PropertyName]
682 if (this.metaData is not
null)
683 foreach (
Property P
in this.metaData)
684 if (
string.Equals(P.
Name, PropertyName, StringComparison.OrdinalIgnoreCase))
712 StringBuilder sb =
new();
730 return sb.ToString();
XMPP Protocol Properties.
const string MeterNumber
MeterNumber
const string PersonalNumber
Personal number
const string Country
Country
const string SerialNumber
Serial Number
const string Region
Region
const string OrgRole
Organization Role
const string StreetName
Street Name
const string Phone
Phone number
const string MiddleNames
Middle names
const string OrgDepartment
Organization Department
const string Domain
Domain name.
const string StreetNumber
Street Number
const string Building
Building
const string LastNames
Last names
const string MeterLocation
Meter Location
const string Manufacturer
Manufacturer
const string Version
Version
const string FirstName
First name
const string Apartment
Apartment
const string OrgName
Organization name
A set of never changing property constants and helpful values.
Base class that references services in the app.
static ITagProfile TagProfile
TAG Profile service.
static IStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
string Name
Name of property
string Value
Property value
Maintains information about an item in the roster.
string NameOrBareJid
Returns the name of the contact, or the Bare JID, if there's no name provided.
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....
CaseInsensitiveString Substring(int startIndex, int length)
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Static interface for database persistence. In order to work, a database provider has to be assigned t...
This filter selects objects that conform to all child-filters provided.
This filter selects objects that have a named field equal to a given value.
TypeNameSerialization
How the type name should be serialized.