Exemplo n.º 1
0
 public override void Execute(
     IViewModel ownerVM,
     ChangeArgs args,
     DeclarativeDependency dependency
     )
 {
     _action((TOwnerVM)ownerVM, args);
 }
Exemplo n.º 2
0
        //internal IList<IPropertySelector> TargetProperties {
        //   get { return _targetProperties; }
        //}

        public override void Execute(
            IViewModel ownerVM,
            ChangeArgs args,
            DeclarativeDependency dependency
            )
        {
            _target.Revalidate(ownerVM);
            //if (TargetPath.IsEmpty) {
            //   RevalidateProperties(ownerVM);
            //} else {
            //   var viewModels = TargetPath.GetDescendants(ownerVM);

            //   foreach (var viewModel in viewModels) {
            //      if (_targetProperties.Count > 0) {
            //         RevalidateProperties(viewModel);
            //      } else {
            //         viewModel.Kernel.Revalidate(ValidationScope.SelfAndLoadedDescendants);
            //      }
            //   }
            //}
        }
Exemplo n.º 3
0
 public void AddDependency(DeclarativeDependency dependency)
 {
     _dependencies.Add(dependency);
 }
Exemplo n.º 4
0
        //internal IList<IPropertySelector> TargetProperties {
        //   get { return _targetProperties; }
        //}

        public override void Execute(
            IViewModel ownerVM,
            ChangeArgs args,
            DeclarativeDependency dependency
            )
        {
            RefreshReason reason = args.Reason as RefreshReason;

            if (reason != null && !reason.ExecuteRefreshDependencies)
            {
                return;
            }

            RefreshTrace.BeginRefresh(dependency);

            _target.ForeachLoadedDescendant(ownerVM, (vm, props) => {
                if (props.Any())
                {
                    // TODO: The logic with 'wouldRefreshChangeSource' is not correct. The refresh source
                    //       may be an descendant of 'vm' in which case it would nevertheless be refreshed.
                    //       Unit test 'SetValue_WhenValidationResultChanges_WorksWithSelfRecursiveDependency'
                    //       reproduces this.
                    foreach (var prop in props)
                    {
                        bool wouldRefreshChangeSource =
                            vm == args.ChangedVM &&
                            prop == args.ChangedProperty;

                        if (!wouldRefreshChangeSource)
                        {
                            vm.Kernel.RefreshInternal(prop, new RefreshOptions(_executeRefreshDependencies));
                        }
                    }
                }
                else
                {
                    bool wouldRefreshChangeSource = vm == args.ChangedVM;

                    if (!wouldRefreshChangeSource)
                    {
                        vm.Kernel.RefreshInternal(_executeRefreshDependencies);
                    }
                }
            });

            //_target.Refresh(ownerVM, _executeRefreshDependencies);

            //ownerVM.Kernel.RefreshInternal(_target, _executeRefreshDependencies);

            //if (TargetPath.IsEmpty) {
            //   if (_targetProperties.Count > 0) {
            //      RefreshProperties(ownerVM);
            //   } else {
            //      ownerVM.Kernel.RefreshInternal(_executeRefreshDependencies);
            //   }
            //} else {
            //   var viewModels = TargetPath.GetDescendants(ownerVM);

            //   foreach (var viewModel in viewModels) {
            //      if (_targetProperties.Count > 0) {
            //         RefreshProperties(viewModel);
            //      } else {
            //         viewModel.Kernel.RefreshInternal(_executeRefreshDependencies);
            //      }
            //   }
            //}

            RefreshTrace.EndLastRefresh();
        }