/// <summary> /// Refresh key and property values. Call after Save to capture database updated keys and values. /// </summary> public AuditLog Refresh() { // update current values because the entites can change after submit foreach (var auditEntity in Entities) { // don't need to update deletes if (auditEntity.Action == AuditAction.Deleted) { continue; } // if current is stored, it will be updated on submit object current = auditEntity.Current; if (current == null) { continue; } // update the key value foreach (var key in auditEntity.Keys) { key.Value = LateBinder.GetProperty(current, key.Name); } // update the property current values foreach (var property in auditEntity.Properties.Where(p => !p.IsRelationship)) { property.Current = LateBinder.GetProperty(current, property.Name); } } return(this); }
public void GetPropertyValueBoxed() { Tester tester = new Tester(); var id = LateBinder.GetProperty(tester, "Id"); Assert.AreEqual(888, id); }
public void GetPropertyValue() { Tester tester = new Tester(); string name = LateBinder.GetProperty(tester, "Name").ToString(); Assert.AreEqual("test", name); }
public void GetPropertyValueNested() { Tester tester = new Tester(); tester.Order = new Order(); string name = LateBinder.GetProperty(tester, "Order.Id").ToString(); Assert.AreEqual("123", name); }
public static bool CanSelectMultipleItems(this ItemsControl itemsControl) { if (itemsControl is MultiSelector) { return((bool)LateBinder.GetProperty(itemsControl, "CanSelectMultipleItems", BindingFlags.Instance | BindingFlags.NonPublic)); } if (itemsControl is ListBox) { return(((ListBox)itemsControl).SelectionMode != SelectionMode.Single); } return(false); }
private static string Evaluate(object source, string expression) { string format = ""; int colonIndex = expression.IndexOf(':'); if (colonIndex > 0) { format = expression.Substring(colonIndex + 1); expression = expression.Substring(0, colonIndex); } try { object value = LateBinder.GetProperty(source, expression) ?? string.Empty; return(string.IsNullOrEmpty(format) ? value.ToString() : string.Format("{0:" + format + "}", value)); } catch (InvalidOperationException ex) { throw new FormatException("One of the identified items was in an invalid format.", ex); } }