コード例 #1
0
 public void ComboButtonClickEvent(object sender, MenuSelectionEvent e)
 {
     if (e.fooditem is ComboOrder combo) // this will check if an object is a certain type
     {
         //newOrder.Add(combo.Entree);
         //newOrder.Add(combo.Drink);
         //newOrder.Add(combo.Side);
         newOrder.Add(combo);
     }
     DisplayCurrentOrder();
 }
コード例 #2
0
        public AppOrder GetAppOrder(string packageName)
        {
            lock (orderingLockObj) {
                var order = Ordering.FirstOrDefault(ao => ao.PackageName.Equals(packageName));

                // Make sure the current ordering actually exists
                if (order == null)
                {
                    var index = 1;
                    // If it doesn't exist, let's assume last in line
                    var after = Ordering.LastOrDefault();
                    if (after != null)
                    {
                        index = after.Order + 1;
                    }

                    // Make our order
                    order = new AppOrder {
                        PackageName = packageName,
                        Order       = index
                    };

                    // Order didn't exist so let's add it
                    Ordering.Add(order);
                }

                return(order);
            }
        }
コード例 #3
0
 public void AddOrder(string key, bool desc = false)
 {
     Ordering.Add(new FilterOrder()
     {
         Key = key, Desc = desc
     });
 }
コード例 #4
0
            public void When_AddingOrderByWithNonComparableProperty_Expect_PropertyNotComparableException()
            {
                // Arrange
                Ordering <TestClass> ordering = new Ordering <TestClass>();

                // Act
                Exception exception = Record.Exception(() => ordering.Add(new OrderBy(nameof(TestClass.Property6))));

                // Assert
                Assert.IsType <PropertyNotComparableException>(exception);
            }
コード例 #5
0
            public void When_AddingOrderByWithNonExistingProperty_Expect_PropertyNotFoundException()
            {
                // Arrange
                Ordering <TestClass> ordering = new Ordering <TestClass>();

                // Act
                Exception exception = Record.Exception(() => ordering.Add(new OrderBy("property1")));

                // Assert
                Assert.IsType <PropertyNotFoundException>(exception);
            }
コード例 #6
0
        public Selector <TField> AddOrderBy(TField field, bool isAsc)
        {
            var orderBy = new OrderBy();

            orderBy.Field     = field.ToString();
            orderBy.SortOrder = isAsc ? SortOrder.Ascending : SortOrder.Descending;
            if (Ordering == null)
            {
                Ordering = new List <OrderBy>();
            }
            Ordering.Add(orderBy);
            return(this);
        }
コード例 #7
0
 public virtual void ReadFrom(XElement xE)
 {
     Fields     = null;
     Predicates = null;
     DateRange  = null;
     Ordering   = null;
     Paging     = null;
     foreach (var xItem in xE.Elements())
     {
         var localName = xItem.Name.LocalName;
         if (localName == "fields")
         {
             if (Fields == null)
             {
                 Fields = new List <string>();
             }
             Fields.Add(xItem.Value);
         }
         else if (localName == "predicates")
         {
             if (Predicates == null)
             {
                 Predicates = new List <Predicate>();
             }
             var predicatesItem = new Predicate();
             predicatesItem.ReadFrom(xItem);
             Predicates.Add(predicatesItem);
         }
         else if (localName == "dateRange")
         {
             DateRange = new DateRange();
             DateRange.ReadFrom(xItem);
         }
         else if (localName == "ordering")
         {
             if (Ordering == null)
             {
                 Ordering = new List <OrderBy>();
             }
             var orderingItem = new OrderBy();
             orderingItem.ReadFrom(xItem);
             Ordering.Add(orderingItem);
         }
         else if (localName == "paging")
         {
             Paging = new Paging();
             Paging.ReadFrom(xItem);
         }
     }
 }
コード例 #8
0
            public void When_OrderingContainsOrderBy_Expect_True()
            {
                // Arrange
                Ordering <TestClass> ordering = new Ordering <TestClass>();
                OrderBy orderby = new OrderBy(nameof(TestClass.Property1));

                ordering.Add(orderby);

                // Act
                bool result = ordering.Contains(orderby);

                // Assert
                Assert.True(result);
            }
コード例 #9
0
ファイル: RequestExtensions.cs プロジェクト: gh0stwizard/VwM
        public static Ordering GetOrderExpression <T>(this Request request)
            where T : class
        {
            var ordering = new Ordering();

            if (request.Order.Count == 0)
            {
                return(ordering);
            }

            request.Order.ForEach(o =>
            {
                var colName = request.Columns[o.Column].Data.ToUpperFirst();

                if (!string.IsNullOrEmpty(colName))
                {
                    ordering.Add(new Tuple <string, string>(colName, o.Direction));
                }
            });

            return(ordering);
        }
コード例 #10
0
        public void OrderingShouldListenForPropertyChanges()
        {
            order.Add(newEntree);
            order.Add(newSide);
            order.Add(newDrink);
            Assert.PropertyChanged(order, "Subtotal", () => newSide.Size = Size.Large);
            Assert.PropertyChanged(order, "Subtotal", () => newSide.Size = Size.Medium);
            Assert.PropertyChanged(order, "Subtotal", () => newSide.Size = Size.Small);
            Assert.PropertyChanged(order, "Tax", () => newSide.Size      = Size.Large);
            Assert.PropertyChanged(order, "Tax", () => newSide.Size      = Size.Medium);
            Assert.PropertyChanged(order, "Tax", () => newSide.Size      = Size.Small);
            Assert.PropertyChanged(order, "Total", () => newSide.Size    = Size.Large);
            Assert.PropertyChanged(order, "Total", () => newSide.Size    = Size.Medium);
            Assert.PropertyChanged(order, "Total", () => newSide.Size    = Size.Small);
            Assert.PropertyChanged(order, "Calories", () => newSide.Size = Size.Large);
            Assert.PropertyChanged(order, "Calories", () => newSide.Size = Size.Medium);
            Assert.PropertyChanged(order, "Calories", () => newSide.Size = Size.Small);

            Assert.PropertyChanged(order, "Subtotal", () => newDrink.Size = Size.Large);
            Assert.PropertyChanged(order, "Subtotal", () => newDrink.Size = Size.Medium);
            Assert.PropertyChanged(order, "Subtotal", () => newDrink.Size = Size.Small);
            Assert.PropertyChanged(order, "Tax", () => newDrink.Size      = Size.Large);
            Assert.PropertyChanged(order, "Tax", () => newDrink.Size      = Size.Medium);
            Assert.PropertyChanged(order, "Tax", () => newDrink.Size      = Size.Small);
            Assert.PropertyChanged(order, "Total", () => newDrink.Size    = Size.Large);
            Assert.PropertyChanged(order, "Total", () => newDrink.Size    = Size.Medium);
            Assert.PropertyChanged(order, "Total", () => newDrink.Size    = Size.Small);
            Assert.PropertyChanged(order, "Calories", () => newDrink.Size = Size.Large);
            Assert.PropertyChanged(order, "Calories", () => newDrink.Size = Size.Medium);
            Assert.PropertyChanged(order, "Calories", () => newDrink.Size = Size.Small);
        }