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()); }
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); }
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); }