private static ObjectId FromString(string hex)
{
Contract.Requires(hex != null);
Contract.Requires(oidString.IsMatch(hex));
var bytes = new byte[12];
for (int i = 0; i < 24; i += 2)
{
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
return new ObjectId(bytes);
}