RolePermissionMapper.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System.Collections.ObjectModel;
  2. using MECF.Framework.UI.Client.ClientBase;
  3. using OpenSEMI.ClientBase;
  4. namespace MECF.Framework.UI.Client.CenterViews.Configs.Roles
  5. {
  6. public class RolePermissionMapper
  7. {
  8. private RolePermissionMapper()
  9. {
  10. _DicPermission.Add(new PermissionType()
  11. { EnumPermission = MenuPermissionEnum.MP_NONE,
  12. StringPermission = "NONE"
  13. });
  14. _DicPermission.Add(new PermissionType()
  15. {
  16. EnumPermission = MenuPermissionEnum.MP_READ,
  17. StringPermission = "Read"
  18. });
  19. _DicPermission.Add(new PermissionType()
  20. {
  21. EnumPermission = MenuPermissionEnum.MP_READ_WRITE,
  22. StringPermission = "Read & Write"
  23. });
  24. }
  25. private static RolePermissionMapper _Instance = null;
  26. public static RolePermissionMapper Instance
  27. {
  28. get
  29. {
  30. if (_Instance == null)
  31. {
  32. _Instance = new RolePermissionMapper();
  33. }
  34. return _Instance;
  35. }
  36. }
  37. private ObservableCollection<PermissionType> _DicPermission = new ObservableCollection<PermissionType>();
  38. public ObservableCollection<PermissionType> PermissionDictionary
  39. {
  40. get { return _DicPermission; }
  41. }
  42. public int ToInt(MenuPermissionEnum enumPermistion)
  43. {
  44. return (int)enumPermistion;
  45. }
  46. public string ToString(MenuPermissionEnum enumPermistion)
  47. {
  48. foreach (PermissionType pd in _DicPermission)
  49. {
  50. if (pd.EnumPermission == enumPermistion)
  51. {
  52. return pd.StringPermission;
  53. }
  54. }
  55. return "";
  56. }
  57. }
  58. public class PermissionType
  59. {
  60. public MenuPermissionEnum EnumPermission{get;set;}
  61. public string StringPermission { get; set; }
  62. }
  63. }