コード例 #1
0
 public CurrentOrderWindow(PizzaOrder order)
 {
     InitializeComponent();
     // show the current order by binding to a collection of one.
     m_currentOrder   = new ObservableCollection <PizzaOrder>();
     this.DataContext = m_currentOrder;
     m_currentOrder.Add(order);
 }
コード例 #2
0
        private static PizzaOrder GenerateRandomOrder(OrderSource source)
        {
            // source
            var order = new PizzaOrder {
                Source = source
            };

            // delivery
            order.IsDelivery = m_rand.Next(0, 2) == 0 ? true : false;
            // phone number
            var areaCode         = m_rand.Next(0, 2) == 0 ? 425 : 206;
            var firstThreeDigits = m_rand.Next(100, 1000);
            var lastFourDigits   = m_rand.Next(0, 10000);

            order.PhoneNumber = String.Format("({0}) {1}-{2}", areaCode, firstThreeDigits, lastFourDigits.ToString("D4"));
            // size
            switch (m_rand.Next(0, 3))
            {
            case 0: order.Size = 11; break;

            case 1: order.Size = 13; break;

            case 2: order.Size = 17; break;
            }
            // toppings
            var availToppings = new List <PizzaToppings>(Enum.GetValues(typeof(PizzaToppings)).Cast <PizzaToppings>());

            order.Toppings = new PizzaToppings[m_rand.Next(1, 5)];
            for (int j = 0; j < order.Toppings.Length; ++j)
            {
                var toppingIndex = m_rand.Next(0, availToppings.Count);
                order.Toppings[j] = availToppings[toppingIndex];
                availToppings.RemoveAt(toppingIndex);
            }
            return(order);
        }