Ejemplo n.º 1
0
        public LimitAttribute(IntegerLimit limitType)
        {
            switch (limitType)
            {
            case IntegerLimit.Rating:
                this.LowLimit = -2;
                this.UpLimit  = 10;
                break;

            case IntegerLimit.RatingLarge:
                this.LowLimit = -2;
                this.UpLimit  = 100;
                break;

            case IntegerLimit.PositiveOrZero:
                this.LowLimit = 0;
                this.UpLimit  = Int32.MaxValue;
                break;

            case IntegerLimit.Positive:
                this.LowLimit = 1;
                this.UpLimit  = Int32.MaxValue;
                break;
            }
        }
Ejemplo n.º 2
0
        private int GetRandomValue(int value, IntegerLimit limit)
        {
            int Result = 0;

            switch (limit)
            {
            case IntegerLimit.Rating:
                if (value == 0)
                {
                    Result = this.random.Next(1, 10);
                }
                else if (value == -1)
                {
                    Result = this.random.Next(5, 7);
                }
                else if (value == -2)
                {
                    Result = this.random.Next(8, 10);
                }
                break;

            case IntegerLimit.RatingLarge:
                if (value == 0)
                {
                    Result = this.random.Next(1, 100);
                }
                else if (value == -1)
                {
                    Result = this.random.Next(50, 79);
                }
                else if (value == -2)
                {
                    Result = this.random.Next(80, 100);
                }
                break;

            default:
                throw new ArgumentException("Аргумент 'limit' должен иметь значение 'Rating' или 'RatingLarge'");
            }
            return(Result);
        }