3using System.Globalization;
16 [CollectionName(
"ContactInformation")]
18 [Index(
"BareJid",
"SourceId",
"Partition",
"NodeId")]
19 [Index(
"IsThing",
"BareJid",
"SourceId",
"Partition",
"NodeId")]
23 private string? objectId =
null;
28 private string friendlyName =
string.Empty;
29 private string sourceId =
string.Empty;
30 private string partition =
string.Empty;
31 private string nodeId =
string.Empty;
33 private bool? subscribeTo =
null;
34 private bool? allowSubscriptionFrom =
null;
35 private bool? isThing =
null;
36 private bool? isSensor =
null;
37 private bool? isActuator =
null;
38 private bool? isConcentrator =
null;
39 private bool? supportsSensorEvents =
null;
40 private bool? owner =
null;
56 set => this.objectId = value;
65 set => this.bareJid = value;
74 set => this.legalId = value;
83 get => this.legalIdentity;
84 set => this.legalIdentity = value;
90 [DefaultValueStringEmpty]
93 get => this.friendlyName;
94 set => this.friendlyName = value;
102 get => this.sourceId;
103 set => this.sourceId = value;
111 get => this.partition;
112 set => this.partition = value;
121 set => this.nodeId = value;
129 get => this.registryJid;
130 set => this.registryJid = value;
138 get => this.subscribeTo;
139 set => this.subscribeTo = value;
147 get => this.allowSubscriptionFrom;
148 set => this.allowSubscriptionFrom = value;
157 set => this.isThing = value;
165 get => this.isSensor;
166 set => this.isSensor = value;
174 get => this.supportsSensorEvents;
175 set => this.supportsSensorEvents = value;
183 get => this.isActuator;
184 set => this.isActuator = value;
192 get => this.isConcentrator;
193 set => this.isConcentrator = value;
203 set => this.owner = value;
212 get => this.metaData;
213 set => this.metaData = value;
268 string Account = RemoteId.
Substring(0, i);
272 if (AccountIsGuid = Guid.TryParse(Account, out Guid
_))
284 if (Info is not
null)
296 if (!
string.IsNullOrEmpty(s))
302 if (Item is not
null)
306 if (identityCache.TryGetValue(RemoteId, out
LegalIdentity? Id))
310 AccountIsGuid =
false;
315 identityCache[RemoteId] =
null;
317 Task
_ = Task.Run(async () =>
324 identityCache[RemoteId] = Id;
336 private static readonly Dictionary<CaseInsensitiveString, LegalIdentity?> identityCache = [];
345 if (RemoteId is
null)
348 int i, c = RemoteId.Length;
349 string[] Result =
new string[c];
351 for (i = 0; i < c; i++)
364 string? Apartment =
null;
366 string? Building =
null;
368 string? Class =
null;
369 string? Country =
null;
370 string? Manufacturer =
null;
371 string? MeterLocation =
null;
372 string? MeterNumber =
null;
373 string? Model =
null;
375 string? Region =
null;
377 string? SerialNumber =
null;
378 string? Street =
null;
379 string? StreetNumber =
null;
380 string? Version =
null;
381 string? Phone =
null;
384 switch (P.
Name.ToUpper(CultureInfo.InvariantCulture))
419 StreetNumber = P.
Value;
427 Manufacturer = P.
Value;
431 MeterLocation = P.
Value;
435 MeterNumber = P.
Value;
447 SerialNumber = P.
Value;
459 StringBuilder? sb =
null;
461 AppendName(ref sb, Class);
462 AppendName(ref sb, Model);
463 AppendName(ref sb, Version);
464 AppendName(ref sb, Room);
465 AppendName(ref sb, Name);
466 AppendName(ref sb, Apartment);
467 AppendName(ref sb, Building);
468 AppendName(ref sb, Street);
469 AppendName(ref sb, StreetNumber);
470 AppendName(ref sb, Area);
471 AppendName(ref sb, City);
472 AppendName(ref sb, Region);
473 AppendName(ref sb, Country);
474 AppendName(ref sb, MeterNumber);
475 AppendName(ref sb, MeterLocation);
476 AppendName(ref sb, Manufacturer);
477 AppendName(ref sb, SerialNumber);
478 AppendName(ref sb, Phone);
480 return sb?.ToString();
490 if (Identity is
null)
493 string? FirstName =
null;
494 string? MiddleName =
null;
495 string? LastName =
null;
496 string? PersonalNumber =
null;
497 string? Domain =
null;
498 string? OrgDepartment =
null;
499 string? OrgRole =
null;
500 string? OrgName =
null;
501 bool HasName =
false;
503 bool HasDomain =
false;
505 foreach (
Property P
in Identity.Properties)
507 switch (P.
Name.ToUpper(CultureInfo.InvariantCulture))
515 MiddleName = P.
Value;
525 PersonalNumber = P.
Value;
534 OrgDepartment = P.
Value;
550 StringBuilder? sb =
null;
554 AppendName(ref sb, FirstName);
555 AppendName(ref sb, MiddleName);
556 AppendName(ref sb, LastName);
561 AppendName(ref sb, OrgRole);
562 AppendName(ref sb, OrgDepartment);
563 AppendName(ref sb, OrgName);
566 string Result = sb is not
null ? sb.ToString() : !
string.IsNullOrEmpty(PersonalNumber) ? PersonalNumber : Identity.Id;
569 Result = Domain +
" (" + Result +
")";
580 string? FirstName =
null;
581 string? MiddleNames =
null;
582 string? LastNames =
null;
584 if (Identity?.Properties is not
null)
585 foreach (
Property P
in Identity.Properties)
597 MiddleNames = P.
Value;
601 return GetFullName(FirstName, MiddleNames, LastNames);
610 public static string GetFullName(
string? FirstName,
string? MiddleNames,
string? LastNames)
612 StringBuilder? sb =
null;
614 AppendName(ref sb, FirstName);
615 AppendName(ref sb, MiddleNames);
616 AppendName(ref sb, LastNames);
618 return sb?.ToString() ??
string.Empty;
626 internal static void AppendName(ref StringBuilder? sb,
string? Value)
628 if (!
string.IsNullOrEmpty(Value))
631 sb =
new StringBuilder();
649 if (
string.IsNullOrEmpty(
NodeId) &&
string.IsNullOrEmpty(PartitionId) &&
string.IsNullOrEmpty(
SourceId))
654 if (Thing is not
null)
659 if (!
string.IsNullOrEmpty(PartitionId))
660 if (
string.IsNullOrEmpty(s))
665 if (!
string.IsNullOrEmpty(
SourceId))
666 if (
string.IsNullOrEmpty(s))
679 public string this[
string PropertyName]
683 if (this.metaData is not
null)
684 foreach (
Property P
in this.metaData)
685 if (
string.Equals(P.
Name, PropertyName, StringComparison.OrdinalIgnoreCase))
713 StringBuilder sb =
new();
731 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.
A strongly-typed resource class, for looking up localized strings, etc.
static string XInY
Looks up a localized string similar to {0} in {1}.
static string Me
Looks up a localized string similar to (me).
static string XOnY
Looks up a localized string similar to {0} on {1}.
Base class that references services in the app.
static ITagProfile TagProfile
TAG Profile service.
static IReportingStringLocalizer 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.