Ejemplo n.º 1
0
        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());
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 private object GetValue(object source)
 {
     return(DotPath.GetDotPathValue(source, Path));
 }