UserControlBase.cs 876 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Controls;
  6. using Aitex.Core.Account;
  7. using Aitex.Core.Util;
  8. namespace Aitex.Triton160.UI.Views
  9. {
  10. public static class UserControlExtender
  11. {
  12. /// <summary>
  13. /// 对UserControl类进行扩展
  14. /// </summary>
  15. /// <param name="userControl"></param>
  16. /// <returns></returns>
  17. public static ViewPermission GetPermission(this UserControl userControl)
  18. {
  19. var account = Globals.Session["CurrentUser"] as Account;
  20. if (account == null) return ViewPermission.Invisiable;
  21. var userControlName = userControl.Name;
  22. if (!account.Permission.ContainsKey(userControlName)) return ViewPermission.Invisiable;
  23. return account.Permission[userControlName];
  24. }
  25. }
  26. }