public AttachedDocumentView() { _disposableContext = new DisposableContext(this); InitializeComponent(); _removeMenuItem = ((ContextMenu)this.RootGrid.Resources["DataGridRowMenu"]).Items.Cast <MenuItem>() .First(x => x.Name == "RemoveRowMenuItem"); _defaultImage = new BitmapImage(new Uri("/Assets/NoImage.png", UriKind.RelativeOrAbsolute)); Loaded += (sender, args) => ReBind(); Unloaded += (sender, args) => _disposableObject.Dispose(); }
public void DisposableObjectIsDisposedAfterDisposal() { DisposableObject disp = new DisposableObject(); disp.Dispose(); Assert.True(disp.IsDisposed); }
public void Dispose() { if (_beginInsertCommand != null) { _beginInsertCommand.Dispose(); _beginInsertCommand = null; } if (_applyInsertCommand != null) { _applyInsertCommand.Dispose(); _applyInsertCommand = null; } if (_cancelAddingCommand != null) { _cancelAddingCommand.Dispose(); _cancelAddingCommand = null; } if (_removeDocumentCommand != null) { _removeDocumentCommand.Dispose(); _removeDocumentCommand = null; } _disposableObject.Dispose(); HasDocument = null; _disposedNotification.OnNext(Unit.Default); }
public override void Intercept(IPlanReceiptOrderViewModel interceptableObject) { lock (_locker) { _weakReference = new WeakReference(interceptableObject); _disposableObject.Dispose(); _disposableObject.Add(Listen()); } }
public void SetSetting(ColorSetting setting) { _colorSetting = setting; Color = setting.Accent; Theme = setting.Theme; _disposableObject.Dispose(); _disposableObject.Add(this.Binding()); }
public override void Intercept(IActSelectionOfProbeViewModel interceptableObject) { lock (_locker) { _weakReference = new WeakReference(interceptableObject); _disposableObject.Dispose(); _disposableObject.Add(this.Listen()); } }
public override void Intercept(IPlanCertificateViewModel interceptableObject) { lock (_locker) { _weakReference = new WeakReference(interceptableObject); _disposableObject.Dispose(); _disposableObject.Add(this.Listen()); } }
private object GetViewModel([NotNull] Type viewModelType, IObservable <Unit> _destroyObservable = null) { Contract.Requires(viewModelType != null); Contract.Ensures(Contract.Result <object>() != null); if (viewModelType.GetInterface("IDisposable") == null) { var viewModel = _dependencyResolver.GetService(viewModelType); if (viewModel == null) { throw new InvalidOperationException( "(RoutableViewModelManager.Get<>) Not resolve {0}".StringFormat(viewModelType)); } return(viewModel); } var exportFactoryInstantiatorType = typeof(ExportFactoryInstantiator <>).MakeGenericType(viewModelType); dynamic exportFactoryInstantiator = _dependencyResolver.GetService(exportFactoryInstantiatorType); if (exportFactoryInstantiator == null) { throw new InvalidOperationException( "(RoutableViewModelManager.Get<>) Not resolve {0}".StringFormat(viewModelType)); } var disposable = new DisposableObject(); Action disposeAction = () => { exportFactoryInstantiator.DisposeOnDemand(); disposable.Dispose(); }; if (_destroyObservable != null) { disposable.Add(_destroyObservable.Subscribe(_ => disposeAction())); } else { disposable.Add( _screen.Router.NavigationStack.ItemsRemoved.Where( viewModel => object.ReferenceEquals(viewModel, exportFactoryInstantiator.Instance)) .Subscribe(viewModel => disposeAction())); } var resolvedViewModel = exportFactoryInstantiator.Instance; return(resolvedViewModel); }
public void Init(IBindableView view) { var disposableObject = new DisposableObject(); disposableObject.Add(view.Binding()); IDisposable disposable = Disposable.Empty; disposable = view.DisposableNotification().Subscribe( _ => { disposable.Dispose(); disposableObject.Dispose(); DisposableObject obj; _dictionary.TryRemove(view, out obj); }); _dictionary.TryAdd(view, disposableObject); }
public void Dispose() { _disposableObject.Dispose(); _hasDocument = null; _disposedNotification.OnNext(Unit.Default); }
private void InterceptableObjectUnloaded(object sender, RoutedEventArgs e) { ((PostingOfInventoryAtTheWarehouseView)sender).Unloaded -= InterceptableObjectUnloaded; _disposable.Dispose(); }
public void Dispose() { _disposables.Dispose(); _disposableNotification.OnNext(Unit.Default); }
protected virtual void ReleaseService(object serviceInstance) { DisposableObject.Dispose(serviceInstance); }