TypeHandle.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Apache.NMS;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.Diagnostics.SymbolStore;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace EasyMQ
  10. {
  11. internal struct TypeHandle
  12. {
  13. public RuntimeTypeHandle First;
  14. public RuntimeTypeHandle Second;
  15. public override bool Equals(object? obj)
  16. {
  17. if (obj is TypeHandle handle)
  18. {
  19. return handle.First.Value == First.Value && handle.Second.Value == Second.Value;
  20. }
  21. else return false;
  22. }
  23. public static bool operator == (TypeHandle handle1,TypeHandle handle2)
  24. {
  25. return (handle1.Second.Value == handle2.Second.Value) && (handle2.First.Value == handle1.First.Value);
  26. }
  27. public static bool operator !=(TypeHandle handle1, TypeHandle handle2)
  28. {
  29. return (handle1.Second.Value != handle2.Second.Value) || (handle2.First.Value != handle1.First.Value);
  30. }
  31. public override int GetHashCode()
  32. {
  33. return First.GetHashCode() | Second.GetHashCode();
  34. }
  35. public static TypeHandle GetHandle<TFirst,TSecond>()
  36. {
  37. return new TypeHandle()
  38. {
  39. First = typeof(TFirst).TypeHandle,
  40. Second = typeof(TSecond).TypeHandle
  41. };
  42. }
  43. }
  44. internal sealed class MQHandle
  45. {
  46. public MQHandle(IMessageProducer producer, IMessageConsumer consumer)
  47. {
  48. Producer = producer;
  49. Consumer = consumer;
  50. }
  51. public Apache.NMS.IMessageProducer Producer { get; }
  52. public Apache.NMS.IMessageConsumer Consumer { get; }
  53. }
  54. }