Esempio n. 1
0
        /// <summary>
        /// The run method with each time.
        /// </summary>
        /// <param name="invoke">
        /// The invoke.
        /// </param>
        /// <param name="count">
        /// The count.
        /// </param>
        /// <param name="typesOfDrawn">
        /// The t drawn.
        /// </param>
        private void RunMethodWithEachTime(MethodInfo invoke, int count, Enums.TypesOfDrawn typesOfDrawn)
        {
            if (LotteryModels == null)
            {
                LotteryModels = new List <LotteryModel>();
            }
            Console.WriteLine(typesOfDrawn.ToString());
            int index = 0;

            while (true)
            {
                var returnedModel = (LotteryModel)invoke.Invoke(this, null);

                if (returnedModel == null)
                {
                    continue;
                }
                if (LotteryModels.AddValueWithDetailsAndValidation(returnedModel.ValidationTuple(), typesOfDrawn))
                {
                    index++;
                    OnLotteryModelEvent(returnedModel);
                }
                else
                {
                    continue;
                }

                if (index == count)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The run method with each time.
        /// </summary>
        /// <param name="invoke">
        /// The invoke.
        /// </param>
        /// <param name="count">
        /// The count.
        /// </param>
        /// <param name="typesOfDrawn">
        /// The t drawn.
        /// </param>
        private void RunMethodWithEachTime(MethodInfo invoke, int count, Enums.TypesOfDrawn typesOfDrawn)
        {
            if (LotteryModels == null)
            {
                LotteryModels = new List <LotteryModel>();
            }
            Console.WriteLine(typesOfDrawn.ToString());
            int index        = 0;
            int errorCounter = 0;
            int skipRutinWhenReachThisNumber = 200;

            while (true)
            {
                var returnedModel = (LotteryModel)invoke.Invoke(this, null);
                if (skipRutinWhenReachThisNumber == errorCounter)
                {
                    Console.WriteLine("You cant genreate numbers with this method, because numbers dosent right for it");
                    break;
                }

                if (returnedModel == null)
                {
                    errorCounter++;
                    continue;
                }

                if (LotteryModels.AddValueWithDetailsAndValidation(returnedModel.ValidationTuple(), typesOfDrawn))
                {
                    index++;
                    OnLotteryModelEvent(returnedModel);
                }
                else
                {
                    continue;
                }

                if (index == count)
                {
                    break;
                }
            }
        }