/// <summary> /// 安全地读入指定字段的名称 /// </summary> /// <param name="bsonReader">Bson读取器</param> /// <param name="expected">字段名</param> /// <param name="read">字段名缓存</param> /// <returns>是否可以继续读入</returns> private static bool ReadName(this IBsonReader bsonReader, string expected, ref string read) { if (bsonReader.IsEndOfDocument()) { return(false); } read ??= bsonReader.ReadName(); if (read != expected) { return(false); } read = null; return(true); }