コード例 #1
0
        public IEnumerator <T> GetEnumerator()
        {
            if (sortProperty != null)
            {
                if (sortAsc)
                {
                    return(items.Values.OrderBy(x => sortProperty.GetValue(x)).GetEnumerator());
                }
                else
                {
                    return(items.Values.OrderByDescending(x => sortProperty.GetValue(x)).GetEnumerator());
                }
            }

            return(items.Values.GetEnumerator());
        }
コード例 #2
0
        public void TestJObjectAccess()
        {
            var foo = new Foo()
            {
                Name = "Test",
                Age  = 22
            };

            var ep     = new ExpressionProperty <Foo>(JObject.FromObject(foo));
            var result = ep.GetValue(new object());

            Assert.AreEqual("Test", result.Name);
            Assert.AreEqual(22, result.Age);
        }
コード例 #3
0
        public void TestExpressionAccess()
        {
            var state = new
            {
                test = new Foo()
                {
                    Name = "Test",
                    Age  = 22
                }
            };

            var ep     = new ExpressionProperty <Foo>("test");
            var result = ep.GetValue(state);

            Assert.AreEqual("Test", result.Name);
            Assert.AreEqual(22, result.Age);
        }