public void Refresh( bool executeRefreshDependencies = false ) { RefreshTrace.BeginManualRefresh(); RefreshInternal(executeRefreshDependencies); RefreshTrace.EndLastRefresh(); }
public void RefreshContainer( IVMPropertyDescriptor property, bool executeRefreshDependencies = false ) { RefreshTrace.BeginManualRefresh(); RefreshInternal(property, new RefreshOptions(RefreshScope.Container, executeRefreshDependencies)); RefreshTrace.EndLastRefresh(); }
public void Refresh(IBehaviorContext context, IVMPropertyDescriptor property, RefreshOptions options) { RefreshTrace.BeginRefresh(property); RequireInitialized(); property.Behaviors.RefreshNext(context, options); this.ViewModelRefreshNext(context, property, options); RefreshTrace.EndLastRefresh(); }
public void Refresh(IBehaviorContext context, bool executeRefreshDependencies) { RefreshTrace.BeginRefresh(context.VM); RequireInitialized(); foreach (IVMPropertyDescriptor property in UpdateFromSourceProperties) { // We call ALL behaviors and not only succeeding ones, because a client // may want to register a behavior that gets called BEFORE this behavior. context .VM .Descriptor .Behaviors .ViewModelRefreshNext(context, property, new RefreshOptions(executeRefreshDependencies)); } this.ViewModelRefreshNext(context, executeRefreshDependencies); RefreshTrace.EndLastRefresh(); }
public void Refresh_OfWrapperCollectionProperty_RefreshesReusedItemVMs() { RefreshTrace.StartTrace(); var sharedSource = new ChildSource(); var reusedVM = new ChildVM(sharedSource); var previousVM = new ChildVM(new ChildSource()); VM.WrapperProperty.Add(reusedVM); VM.WrapperProperty.Add(previousVM); var newSource = new ChildSource(); VM.WrapperPropertySource = new List <ChildSource> { sharedSource, newSource }; VM.Refresh(x => x.WrapperProperty); Assert.AreEqual(2, VM.WrapperProperty.Count); Assert.IsTrue(VM.WrapperProperty[0].WasRefreshed); Assert.IsFalse(VM.WrapperProperty[1].WasRefreshed); }
//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(); }