EventManager.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5. using SimpleJson;
  6. using CommonLang;
  7. namespace Pomelo.DotNetClient
  8. {
  9. public static class EventTypes
  10. {
  11. private static HashMap<string, Type> pushTypeMap = new HashMap<string, Type>();
  12. private static HashMap<Type, string> pushKeyMap = new HashMap<Type, string>();
  13. private static HashMap<Type, string> requestTypeMap = new HashMap<Type, string>();
  14. private static HashMap<Type, string> responseTypeMap = new HashMap<Type, string>();
  15. private static HashMap<string, Type> responseKeyMap = new HashMap<string, Type>();
  16. private static HashMap<Type, string> notifyTypeMap = new HashMap<Type, string>();
  17. public static void RegistPushType(string key, Type value)
  18. {
  19. pushTypeMap.Add(key, value);
  20. pushKeyMap.Add(value, key);
  21. }
  22. public static void RegistRequestType(string key, Type request, Type response)
  23. {
  24. requestTypeMap.Add(request, key);
  25. responseTypeMap.Add(response, key);
  26. responseKeyMap.Add(key, response);
  27. }
  28. public static void RegistNotifyType(string key, Type notify)
  29. {
  30. notifyTypeMap.Add(notify, key);
  31. }
  32. public static Type GetPushType(string key)
  33. {
  34. return pushTypeMap.Get(key);
  35. }
  36. public static string GetPushKey(Type type)
  37. {
  38. return pushKeyMap.Get(type);
  39. }
  40. public static string GetRequestKey(Type type)
  41. {
  42. return requestTypeMap.Get(type);
  43. }
  44. public static string GetResponseKey(Type type)
  45. {
  46. return responseTypeMap.Get(type);
  47. }
  48. public static Type GetResponseType(string key)
  49. {
  50. return responseKeyMap.Get(key);
  51. }
  52. public static string GetNotifyKey(Type type)
  53. {
  54. return notifyTypeMap.Get(type);
  55. }
  56. public static IEnumerable<Type> PushTypes { get { return pushTypeMap.Values; } }
  57. public static IEnumerable<Type> RequestTypes { get { return requestTypeMap.Keys; } }
  58. public static IEnumerable<Type> ResponseTypes { get { return responseTypeMap.Keys; } }
  59. public static IEnumerable<Type> NotifyTypes { get { return notifyTypeMap.Keys; } }
  60. }
  61. }