Пример #1
0
    /// <summary>
    /// 尝试解析指定的值至ObjectId
    /// </summary>
    /// <param name="value">指定的值</param>
    /// <param name="objectId">ObjectId</param>
    /// <returns>是否成功解析</returns>
    public static bool TryParse(string value, out ObjectId objectId)
    {
      objectId = Empty;
      if (value == null || value.Length != 24)
      {
        return false;
      }

      try
      {
        objectId = new ObjectId(value);
        return true;
      }
      catch (FormatException)
      {
        return false;
      }
    }
Пример #2
0
 /// <summary>
 /// Determines whether the specified ObjectId is equal to this instance.
 /// </summary>
 /// <param name="other">The other ObjectId.</param>
 /// <returns>
 ///   <c>true</c> if the specified ObjectId is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 public bool Equals(ObjectId other)
 {
   return other != null && ToString() == other.ToString();
 }