| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using SKMC.Api.Common;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Data;
- namespace SKMC.Api.Client.Access
- {
- /// <summary>
- /// 权限码 -> 是否可见的转换器
- /// </summary>
- public class ClientAccessConverter : IMultiValueConverter
- {
- private readonly IClientRoleAccesser clientRoleAccesser;
- public ClientAccessConverter()
- {
- clientRoleAccesser = ObjectFactory.Resolve<IClientRoleAccesser>();
- }
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values[0] is string accessCode)
- {
- return clientRoleAccesser.HasAccess(accessCode)
- ? Visibility.Visible
- : Visibility.Collapsed;
- }
- return Visibility.Collapsed;
- }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
- }
- }
|