ServerSession.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright 2017-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using MongoDB.Bson;
  17. using MongoDB.Driver.Core.Misc;
  18. namespace MongoDB.Driver
  19. {
  20. /// <summary>
  21. /// A server session.
  22. /// </summary>
  23. /// <seealso cref="MongoDB.Driver.IServerSession" />
  24. internal sealed class ServerSession : IServerSession
  25. {
  26. // private fields
  27. private readonly ICoreServerSession _coreServerSession;
  28. // constructors
  29. public ServerSession(ICoreServerSession coreServerSession)
  30. {
  31. _coreServerSession = Ensure.IsNotNull(coreServerSession, nameof(coreServerSession));
  32. }
  33. // public properties
  34. /// <inheritdoc />
  35. public BsonDocument Id => _coreServerSession.Id;
  36. /// <inheritdoc />
  37. public DateTime? LastUsedAt => _coreServerSession.LastUsedAt;
  38. // public methods
  39. /// <inheritdoc />
  40. [Obsolete("Let the driver handle when to advance the transaction number.")]
  41. public long AdvanceTransactionNumber()
  42. {
  43. // do nothing
  44. return -1;
  45. }
  46. /// <inheritdoc />
  47. public void Dispose()
  48. {
  49. // do nothing (the ServerSession does NOT own the wrapped core server session)
  50. }
  51. /// <inheritdoc />
  52. [Obsolete("Let the driver handle tracking when the session was last used.")]
  53. public void WasUsed()
  54. {
  55. // do nothing
  56. }
  57. }
  58. }