Beispiel #1
0
        public static string GetUniqueString(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");
            }

            if (thingId.Length < (index + 1))
            {
                throw new ArgumentException("Argument does not contain uniqueString.", "thingId");
            }

            string uniqueString = thingId.Substring(index + 1);

            if (!ThingIdHelper.CheckUniqueString(uniqueString))
            {
                throw new ArgumentException("Argument does not contain uniqueString.", "thingId");
            }

            return(uniqueString);
        }
Beispiel #2
0
        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}");
        }
Beispiel #3
0
        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);
        }