예제 #1
0
        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();
        }
예제 #2
0
        public void DisposableObjectIsDisposedAfterDisposal()
        {
            DisposableObject disp = new DisposableObject();

            disp.Dispose();
            Assert.True(disp.IsDisposed);
        }
예제 #3
0
        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());
        }
예제 #6
0
        public override void Intercept(IActSelectionOfProbeViewModel interceptableObject)
        {
            lock (_locker)
            {
                _weakReference = new WeakReference(interceptableObject);

                _disposableObject.Dispose();
                _disposableObject.Add(this.Listen());
            }
        }
예제 #7
0
        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);
        }
예제 #9
0
        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();
 }
예제 #12
0
 public void Dispose()
 {
     _disposables.Dispose();
     _disposableNotification.OnNext(Unit.Default);
 }
예제 #13
0
 protected virtual void ReleaseService(object serviceInstance)
 {
     DisposableObject.Dispose(serviceInstance);
 }