Ejemplo n.º 1
0
        public static bool usernameIsValid(string Username)
        {
            const string Allowed = "1234567890qwertyuiopasdfghjklzxcvbnm-+=?!@:.,$";

            foreach (char chr in Username.ToLower())
            {
                if (!Allowed.Contains(chr.ToString()))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
     public IEnumerable <ModelValidationResult> Validate(ModelValidationContext context)
     {
         if (Allowed.Contains(context.Model as string))
         {
             return(Enumerable.Empty <ModelValidationResult>());
         }
         else
         {
             return new List <ModelValidationResult> {
                        new ModelValidationResult("", ErrorMessage)
             }
         };
     }
 }
Ejemplo n.º 3
0
        private void Search(int Col, Allowed allowed)
        {
            // Go thru the columns
            for (int iCol = Col; iCol < m_gridMax + 1; iCol++)
            {
                if (iCol == m_gridMax)
                {
                    // Success!!!
                    m_results.Add(m_result);
                    m_result = (int[])m_result.Clone();
                }
                else
                {
                    // Go thru the rows
                    for (int iRow = 0; iRow < m_gridMax + 1; iRow++)
                    {
                        if (iRow == m_gridMax)
                        {
                            // Not in this column!!!
                            m_result[iCol] = 0;
                            return;
                        }
                        else
                        {
                            if (allowed.Back[iCol + iRow] == false &&
                                allowed.Front[iCol - iRow + m_gridMax - 1] == false &&
                                allowed.Row[iRow] == false)
                            {
                                Allowed allowedNew = new Allowed();

                                allowedNew.Column = (bool[])allowed.Column.Clone();
                                allowedNew.Row    = (bool[])allowed.Row.Clone();
                                allowedNew.Back   = (bool[])allowed.Back.Clone();
                                allowedNew.Front  = (bool[])allowed.Front.Clone();

                                allowedNew.Column[iCol]      = true;
                                allowedNew.Row[iRow]         = true;
                                allowedNew.Back[iCol + iRow] = true;
                                allowedNew.Front[iCol - iRow + m_gridMax - 1] = true;

                                m_result[iCol] = iRow;

                                Search(iCol + 1, allowedNew);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
            public async Task Modify(SocketUser user)
            {
                if (_Muted.Contains(user) && !(user as SocketGuildUser).IsMuted)
                {
                    await Remove(user);
                    await AddAllowed(user);

                    await Console.UpdateObservers($"{user.Username} is now allowed");
                }
                if (Allowed.Contains(user) && (user as SocketGuildUser).IsMuted)
                {
                    await Remove(user);
                    await AddGuest(user);

                    await Console.UpdateObservers($"{user.Username} is now muted");
                }
            }
Ejemplo n.º 5
0
        public IEnumerable <ModelValidationResult> Validate(ModelValidationContext context)
        {
            var stringArray = Allowed.Select(s => s.ToLower()).ToArray();
            var inputString = context.Model as string;

            if (stringArray.Contains(inputString.ToLower()))
            {
                return(Enumerable.Empty <ModelValidationResult>());
            }
            else
            {
                return new List <ModelValidationResult> {
                           new ModelValidationResult("", ErrorMessage)
                }
            };
        }
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Calculates all the positions of the queens in a grid.  Assumes the grid is a square and number of queens is equal to number of columns.
        /// </summary>
        /// <param name="gridSize">The size of the square grid.</param>
        /// <returns>Collection of results. Queen position is Row No = Result[Column#]</returns>
        public ReadOnlyCollection <int[]> Process(int gridSize)
        {
            m_gridMax = gridSize;

            m_result  = new int[m_gridMax];
            m_results = new List <int[]>();

            Allowed allowed = new Allowed();

            allowed.Column = new bool[m_gridMax];
            allowed.Row    = new bool[m_gridMax];
            allowed.Back   = new bool[2 * m_gridMax - 1];
            allowed.Front  = new bool[2 * m_gridMax - 1];

            Search(0, allowed);

            return(new ReadOnlyCollection <int[]>(m_results));
        }
Ejemplo n.º 7
0
        public void Execute()
        {
            IpPolicyModule.SecureOnly = SecureOnly;

            if (!string.IsNullOrEmpty(NoExceptionPathRegex))
            {
                IpPolicyModule.NoExceptionPathRegex = new Regex(NoExceptionPathRegex,
                                                                RegexOptions.IgnoreCase | RegexOptions.Compiled);
            }

            if (Allowed != null && Allowed.Length > 0)
            {
                IpPolicyModule.Allowed(Allowed.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries));
            }

            if (Denied != null && Denied.Length > 0)
            {
                IpPolicyModule.Denied(Denied.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries));
            }
        }
        /// <summary>
        /// Return the hash code of this object.
        /// </summary>
        /// <returns>The hash code of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(Allowed.GetHashCode() * 11 ^
                       Token.GetHashCode() * 7 ^

                       (Location.HasValue
                            ? Location.Value.GetHashCode() * 5
                            : 0) ^

                       (AuthorizationReference.HasValue
                            ? AuthorizationReference.Value.GetHashCode() * 3
                            : 0) ^

                       (Info.HasValue
                            ? Info.Value.GetHashCode()
                            : 0));
            }
        }
Ejemplo n.º 9
0
        public IAclProvider SetAcls(params AccessRule[] acls)
        {
            foreach (AccessRule acl in acls)
            {
                switch (acl.Type)
                {
                case AccessRules.Allow:
                    Allowed.Add(GetAbsoluteResourcePath(acl), acl);
                    break;

                case AccessRules.Deny:
                    Denied.Add(GetAbsoluteResourcePath(acl), acl);
                    break;
                }
                if (AclChanged != null)
                {
                    AclChanged(this, acl.Resource);
                }
            }
            return(this);
        }
Ejemplo n.º 10
0
 public RateLimitingOptions Allow(string name, AsyncSelector <bool> predicate)
 {
     Allowed.Add(new Check(name, predicate));
     return(this);
 }
Ejemplo n.º 11
0
 public override string ToString()
 {
     return(Selected?.ToString() ?? Allowed.ToString());
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Return if are between from an To
 /// </summary>
 /// <param name="o">Object</param>
 public bool ItsValid(T o)
 {
     return(Allowed.Contains(o));
 }
Ejemplo n.º 13
0
 /// <summary>Clones this instance.</summary>
 /// <returns>Deeply cloned instance.</returns>
 public ResourceSecurityInfo Clone()
 {
     return(new ResourceSecurityInfo(Allowed.Clone(), Denied.Clone()));
 }
Ejemplo n.º 14
0
 protected void When(string state, string[] allow)
 {
     Allowed.Add(state, allow);
 }
Ejemplo n.º 15
0
 public bool Has(string socketName)
 {
     return(Allowed.Any(s => s.Name == socketName));
 }