示例#1
0
 public FruitCreatedEvent(string id, decimal weight, FruitCondition condition, TypeOfFruit typeOfFruit)
 {
     Id          = id;
     Weight      = weight;
     Condition   = condition;
     TypeOfFruit = typeOfFruit;
 }
示例#2
0
        public static void Main(string[] args)
        {
            TypeOfFruit fruitList;
            string      userResponce;

            string[]      userFruit    = new string[3];
            TypeOfFruit[] fruitOptions = new TypeOfFruit[8];

            fruitOptions[0] = TypeOfFruit.apple;
            fruitOptions[1] = TypeOfFruit.banana;
            fruitOptions[2] = TypeOfFruit.strawberry;
            fruitOptions[3] = TypeOfFruit.mango;
            fruitOptions[4] = TypeOfFruit.pineapple;
            fruitOptions[5] = TypeOfFruit.pear;
            fruitOptions[6] = TypeOfFruit.watermellon;
            fruitOptions[7] = TypeOfFruit.orange;

            Console.WriteLine("AVALIBLE FRUIT");
            for (int i = 0; i < 8; i++)
            {
                Console.WriteLine(fruitOptions[i]);
            }

            Console.WriteLine("*****************");


            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine();
                Console.Write("What is your " + (i + 1) + " favorite fruit : ");
                userResponce = Console.ReadLine();

                if (Enum.TryParse(userResponce.ToLower(), out fruitList))
                {
                    userFruit[i] = userResponce;
                }
                else
                {
                    Console.WriteLine("Sorry we dont have that kind of fruit");
                    i -= 1;
                }
            }

            Console.WriteLine();

            Console.WriteLine("The fruit you selected is");
            for (int i = 0; i < 3; i++)
            {
                Console.WriteLine(userFruit[i]);
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
        private void Summon(string fruitId, decimal weight, FruitCondition condition, TypeOfFruit type)
        {
            var ev = new FruitCreatedEvent(fruitId, weight, condition, type);

            _events.Add(ev);

            Apply((dynamic)ev);
        }
        public static FruitAggregate CreateNew(string fruitId, decimal weight, FruitCondition condition, TypeOfFruit type)
        {
            var agg = new FruitAggregate();

            agg.Summon(fruitId, weight, condition, type);

            return(agg);
        }