public void Digest(object source) { List <BindingChange> changes = null; for (int i = 0; i < Paths.Length; i++) { var path = Paths[i]; var value = DotPath.GetDotPathValue(source, path); if (value != Values[i]) { //Changed if (changes == null) { changes = new List <BindingChange>(); } changes.Add(new BindingChange() { Path = PathStrings[i], PreviousValue = Values[i], Value = value }); Values[i] = value; } } if (changes != null) { Callback(changes.ToArray()); } }
public Binding <T> WithBinding(object target, string targetProperty, string sourcePath, Func <object, object> valueConverter) { //If top level changes, we need to update children //If member of top level changes, we need to update children var binding = new DotPathBinding(target, targetProperty, DotPath.CompileDotPath(typeof(T), sourcePath), valueConverter); Bindings.Add(binding); return(this); }
public Binding <T> WithMultiBinding(Callback <BindingChange[]> callback, params string[] paths) { var compiledPaths = new PropertyInfo[paths.Length][]; for (int i = 0; i < paths.Length; i++) { compiledPaths[i] = DotPath.CompileDotPath(typeof(T), paths[i]); } var binding = new MultiDotPathBinding(callback, paths, compiledPaths); Bindings.Add(binding); return(this); }
private object GetValue(object source) { return(DotPath.GetDotPathValue(source, Path)); }