DetectService.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using XdCxRhDW.Core.Api;
  7. namespace XdCxRhDW.WebApi.Service
  8. {
  9. /// <summary>
  10. /// 测试Service
  11. /// </summary>
  12. public class DetectService
  13. {
  14. private static readonly object thisLock = new object();
  15. Dictionary<string, XcorrUtils> keyValues = new Dictionary<string, XcorrUtils>();
  16. /// <summary>
  17. ///
  18. /// </summary>
  19. public DetectService()
  20. {
  21. int code = this.GetHashCode();
  22. }
  23. /// <summary>
  24. /// 存储token
  25. /// </summary>
  26. /// <param name="token"></param>
  27. /// <param name="xcorr"></param>
  28. public void Add(string token, XcorrUtils xcorr)
  29. {
  30. lock (thisLock)
  31. {
  32. keyValues.Add(token, xcorr);
  33. }
  34. }
  35. /// <summary>
  36. /// 移除totken
  37. /// </summary>
  38. /// <param name="token"></param>
  39. public void Remove(string token)
  40. {
  41. lock (thisLock)
  42. {
  43. keyValues.Remove(token);
  44. }
  45. }
  46. /// <summary>
  47. ///
  48. /// </summary>
  49. /// <param name="token"></param>
  50. public XcorrUtils Get(string token)
  51. {
  52. lock (thisLock)
  53. {
  54. if (keyValues.ContainsKey(token))
  55. {
  56. return keyValues[token];
  57. }
  58. else
  59. {
  60. return null;
  61. }
  62. }
  63. }
  64. }
  65. }