in csharp/src/Containers/UUID.cs [612:656]
public UUID(IReadOnlyString str, int offset = 0, UUIDParseFormat format = UUIDParseFormat.Any)
{
if (str == null)
throw new ArgumentNullException(nameof(str));
if (str.Length < offset + 32)
throw new ArgumentException("UUID is too short.", nameof(str));
if (format == UUIDParseFormat.Any)
format = str[offset + 8] == '-' ? UUIDParseFormat.AnyCase : UUIDParseFormat.AnyCaseWithoutDashes;
switch (format)
{
case UUIDParseFormat.LowerCase:
case UUIDParseFormat.UpperCase:
case UUIDParseFormat.AnyCase:
{
ulong m = Extract(str, offset, 8, 0UL, format);
if (str[offset + 8] != '-')
throw new ArgumentException("UUID is improperly formatted", str.ToString());
m = Extract(str, offset + 9, 4, m, format);
if (str[offset + 13] != '-')
throw new ArgumentException("UUID is improperly formatted", str.ToString());
m = Extract(str, offset + 14, 4, m, format);
if (str[offset + 18] != '-')
throw new ArgumentException("UUID is improperly formatted", str.ToString());
ulong l = Extract(str, offset + 19, 4, 0L, format);
if (str[offset + 23] != '-')
throw new ArgumentException("UUID is improperly formatted", str.ToString());
l = Extract(str, offset + 24, 12, l, format);
MSB = m;
LSB = l;
break;
}
case UUIDParseFormat.LowerCaseWithoutDashes:
case UUIDParseFormat.UpperCaseWithoutDashes:
case UUIDParseFormat.AnyCaseWithoutDashes:
MSB = Extract(str, offset, 16, 0L, format);
LSB = Extract(str, offset + 16, 16, 0L, format);
break;
default:
throw new ArgumentException("Unsupported format", format.ToString());
}
}