Esempio n. 1
0
        public IPermissionGroup GetPrimaryGroup(IUser user)
        {
            IPermissionGroup group;

            foreach (IPermissionProvider service in ProxiedServices.Where(c => c.SupportsTarget(user)))
            {
                if ((group = service.GetPrimaryGroup(user)) != null)
                {
                    return(group);
                }
            }

            return(null);
        }
Esempio n. 2
0
        public async Task <IPermissionGroup> GetPrimaryGroupAsync(IPermissionEntity user)
        {
            IPermissionGroup group;

            foreach (IPermissionProvider service in ProxiedServices.Where(c => c.SupportsTarget(user)))
            {
                if ((group = await service.GetPrimaryGroupAsync(user)) != null)
                {
                    return(group);
                }
            }

            return(null);
        }
Esempio n. 3
0
        public async Task <bool> HandleCommandAsync(IUser user, string commandLine, string prefix)
        {
            GuardUser(user);

            foreach (ICommandHandler handler in ProxiedServices.Where(c => c.SupportsUser(user)))
            {
                if (await handler.HandleCommandAsync(user, commandLine, prefix))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        public bool HandleCommand(IUser user, string commandLine, string prefix)
        {
            GuardUser(user);

            foreach (ICommandHandler handler in ProxiedServices.Where(c => c.SupportsUser(user.GetType())))
            {
                if (handler.HandleCommand(user, commandLine, prefix))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
        public PermissionResult CheckHasAnyPermission(IIdentity target, params string[] permissions)
        {
            GuardTarget(target);

            foreach (IPermissionProvider provider in ProxiedServices.Where(c => c.SupportsTarget(target)))
            {
                PermissionResult result = provider.CheckHasAnyPermission(target, permissions);
                if (result == PermissionResult.Default)
                {
                    continue;
                }

                return(result);
            }

            return(PermissionResult.Default);
        }
Esempio n. 6
0
        public async Task <PermissionResult> CheckPermissionAsync(IPermissionActor target, string permission)
        {
            GuardTarget(target);

            foreach (IPermissionChecker provider in ProxiedServices.Where(c => c.SupportsTarget(target)))
            {
                PermissionResult result = await provider.CheckPermissionAsync(target, permission);

                if (result == PermissionResult.Default)
                {
                    continue;
                }

                return(result);
            }

            return(PermissionResult.Default);
        }
Esempio n. 7
0
        public async Task <PermissionResult> CheckHasAllPermissionsAsync(IPermissionEntity target, params string[] permissions)
        {
            GuardTarget(target);

            foreach (IPermissionProvider provider in ProxiedServices.Where(c => c.SupportsTarget(target)))
            {
                PermissionResult result = await provider.CheckHasAllPermissionsAsync(target, permissions);

                if (result == PermissionResult.Default)
                {
                    continue;
                }

                return(result);
            }

            return(PermissionResult.Default);
        }
Esempio n. 8
0
 public ICommandProvider GetProvider(string name)
 {
     return(ProxiedServices.FirstOrDefault(c => c.ServiceName.Equals(name, StringComparison.OrdinalIgnoreCase)));
 }
Esempio n. 9
0
 public bool SupportsUser(IUser user)
 {
     return(ProxiedServices.Any(c => c.SupportsUser(user)));
 }
Esempio n. 10
0
 public IEnumerable <IPermissionGroup> GetGroups(IIdentity target)
 {
     return(ProxiedServices.Where(c => c.SupportsTarget(target))
            .SelectMany(c => c.GetGroups(target)));
 }
Esempio n. 11
0
 public bool PluginExists(string name)
 {
     return(ProxiedServices.Any(c => c.PluginExists(name)));
 }
Esempio n. 12
0
 public bool SupportsTarget(IPermissionEntity target)
 {
     return(ProxiedServices.Any(c => c.SupportsTarget(target)));
 }
Esempio n. 13
0
 public async Task <IEnumerable <IPermissionGroup> > GetGroupsAsync()
 {
     return(ProxiedServices.SelectMany(c => c.GetGroupsAsync().GetAwaiter().GetResult()));
 }
Esempio n. 14
0
 public async Task <IEnumerable <string> > GetDeniedPermissionsAsync(IPermissionEntity target, bool inherit = true)
 {
     return(ProxiedServices
            .Where(c => c.SupportsTarget(target))
            .SelectMany(c => c.GetDeniedPermissionsAsync(target, inherit).GetAwaiter().GetResult()));
 }
Esempio n. 15
0
 public IEnumerable <IPermissionGroup> GetGroups()
 {
     return(ProxiedServices.SelectMany(c => c.GetGroups()));
 }
Esempio n. 16
0
 public async Task <IEnumerable <IPermissionGroup> > GetGroupsAsync(IPermissionEntity target)
 {
     return(ProxiedServices.Where(c => c.SupportsTarget(target))
            .SelectMany(c => c.GetGroupsAsync(target).GetAwaiter().GetResult()));
 }
Esempio n. 17
0
 public void Load(IConfigurationContext context)
 {
     ProxiedServices.ForEach(c => c.Load(context));
 }
Esempio n. 18
0
 public bool IsEnabled(LogLevel level)
 {
     return(ProxiedServices.Any(c => c.IsEnabled(level)));
 }
Esempio n. 19
0
 public void Reload()
 {
     ProxiedServices.ForEach(c => c.Reload());
 }
Esempio n. 20
0
 public IEnumerable <string> GetDeniedPermissions(IIdentity target, bool inherit = true)
 {
     return(ProxiedServices
            .Where(c => c.SupportsTarget(target))
            .SelectMany(c => c.GetDeniedPermissions(target, inherit)));
 }
Esempio n. 21
0
 public void Save()
 {
     ProxiedServices.ForEach(c => c.Save());
 }