ServerCallContextAccessor.cs 478 B

123456789101112131415161718
  1. using Grpc.Core;
  2. using System.Threading;
  3. namespace Grpc.Extension.Common.Internal
  4. {
  5. /// <summary>
  6. /// ServerCallContextAccessor
  7. /// </summary>
  8. public static class ServerCallContextAccessor
  9. {
  10. private static readonly AsyncLocal<ServerCallContext> context = new AsyncLocal<ServerCallContext>();
  11. public static ServerCallContext Current {
  12. get { return context.Value; }
  13. set { context.Value = value; }
  14. }
  15. }
  16. }