コード例 #1
0
 /// <summary> Checks whether this command may be called by players of a given rank. </summary>
 public bool CanBeCalledBy([NotNull] Rank rank)
 {
     if (rank == null)
     {
         throw new ArgumentNullException("rank");
     }
     return(Permissions == null ||
            Permissions.All(rank.Can) ||
            AnyPermission && Permissions.Any(rank.Can));
 }
コード例 #2
0
        /// <summary> Checks whether this command may be called by players of a given rank. </summary>
        public bool CanBeCalledBy([NotNull] Rank rank, bool isConsole)
        {
            if (rank == null && !isConsole)
            {
                throw new ArgumentNullException("rank");
            }

            if (isConsole)
            {
                return(true);
            }
            return(Permissions == null ||
                   Permissions.All(rank.Can) ||
                   AnyPermission && Permissions.Any(rank.Can));
        }
コード例 #3
0
        public bool IsSatisfied(PermissionDependencyContext context)
        {
            var session = context.ServiceProvider.GetRequiredService <IUserSession>();

            return(RequiresAll ? Permissions.All(session.IsGranted) : Permissions.Any(session.IsGranted));
        }