public static string Create(string creatorFQDN, string uniqueString, bool allowNull = false) { if (!ThingIdHelper.CheckFQDN(creatorFQDN, allowNull)) { throw new ArgumentException("Argument is not FQDN.", "creatorFQDN"); } if (!ThingIdHelper.CheckUniqueString(uniqueString, allowNull)) { throw new ArgumentException("UniqueString is invalid.", "uniqueString"); } return($"{creatorFQDN}/{uniqueString}"); }
public static string GetFQDN(string thingId) { if (string.IsNullOrWhiteSpace(thingId)) { throw new ArgumentException("Argument is null or empty.", "thingId"); } var index = thingId.IndexOf('/'); if (index < 1) { throw new ArgumentException("Argument does not contain '/'.", "thingId"); } string fqdn = thingId.Substring(0, index); if (!ThingIdHelper.CheckFQDN(fqdn)) { throw new ArgumentException("Argument does not contain FQDN.", "thingId"); } return(fqdn); }