예제 #1
0
 public void Start()
 {
     for (int i = 0; i < 10; i++)
     {
         int randNum = random.Next();
         if (randNum % 2 == 0)
         {
             EvenNumberEvent?.Invoke(this, new EvenEventArgs(randNum));
         }
     }
 }
예제 #2
0
        /// <summary>Send spinning result notifications</summary>
        /// <param name="number">Ranom spinned number</param>
        public void Spin(Number number)
        {
            var sb = new StringBuilder();

            sb.Append($"Players: {SpinEvent.GetInvocationList().Length}, Events: ");

            SpinnerEventArgs spinEventArgs = new SpinnerEventArgs(number);

            if (number.Color == Number.EColor.BLACK)
            {
                sb.Append("BLACK, ");
                BlackColorEvent?.Invoke(this, spinEventArgs);
            }

            if (number.Color == Number.EColor.RED)
            {
                sb.Append("RED, ");
                RedColorEvent?.Invoke(this, spinEventArgs);
            }

            if (number.Color == Number.EColor.GREEN)
            {
                sb.Append("GREEN, ");
                GreenColorEvent?.Invoke(this, spinEventArgs);
            }

            if (number.Value % 2 == 0)
            {
                sb.Append("EVEN, ");
                EvenNumberEvent?.Invoke(this, spinEventArgs);
            }

            if (!(number.Value % 2 == 0))
            {
                sb.Append("ODD, ");
                OddNumberEvent?.Invoke(this, spinEventArgs);
            }

            sb.Append(number.Value);
            LogManager.GetCurrentClassLogger().Info(sb.ToString());
            SpinEvent?.Invoke(this, spinEventArgs);
        }