UserControlBase.cs 790 B

123456789101112131415161718192021222324
  1. using System.Windows.Controls;
  2. using Aitex.Core.Account;
  3. using Aitex.Core.Util;
  4. namespace MECF.Framework.UI.Core.Accounts
  5. {
  6. public static class UserControlExtender
  7. {
  8. /// <summary>
  9. /// 对UserControl类进行扩展
  10. /// </summary>
  11. /// <param name="userControl"></param>
  12. /// <returns></returns>
  13. public static ViewPermission GetPermission(this UserControl userControl)
  14. {
  15. var account = AccountClient.Instance.CurrentUser;
  16. if (account == null) return ViewPermission.Invisiable;
  17. var userControlName = userControl.Name;
  18. if (!account.Permission.ContainsKey(userControlName)) return ViewPermission.Invisiable;
  19. return account.Permission[userControlName];
  20. }
  21. }
  22. }