示例#1
0
        public void Should_Delete_CareKeeperMultiplePayloadFromSameViewModel()
        {
            Guid guid = Guid.NewGuid();
            Uri  uri  = new Uri("karve://suppliers/viewmodel?id=" + guid.ToString());

            // schedule items.
            for (int i = 0; i < 10; ++i)
            {
                DataPayLoad payload = new DataPayLoad();
                payload.DataObject = new SupplierViewObject();
                payload.ObjectPath = uri;
                _careKeeper.Schedule(payload);
            }
            Assert.AreEqual(1, _careKeeper.ScheduledPayloadCount());
            _careKeeper.DeleteItems(uri);
            Assert.AreEqual(0, _careKeeper.ScheduledPayloadCount());
        }
示例#2
0
        public void Should_CareKeeper_SchedulePayload()
        {
            DataPayLoad dataPayLoad = new DataPayLoad();

            dataPayLoad.DataObject    = new MockDataObject();
            dataPayLoad.HasDataObject = true;
            dataPayLoad.ObjectPath    = new Uri("karve://suppliers/viewmodel/id/8393839");
            _keeper.Schedule(dataPayLoad);
            Assert.AreEqual(_keeper.GetScheduledPayload().Count, 1);
        }
        /// <summary>
        ///  Each different subsytem call this method to notify a change in the system to the toolbar.
        /// </summary>
        /// <param name="payload"></param>
        public void IncomingPayload(DataPayLoad payload)
        {
            IsNewEnabled   = true;
            CurrentPayLoad = payload;
            switch (payload.PayloadType)
            {
            // a subsystem has opened a new window with data.
            case DataPayLoad.Type.RegistrationPayload:
            {
                _activeSubSystem = payload.Subsystem;
                IsNewEnabled     = true;
                break;
            }

            case DataPayLoad.Type.Delete:
            {
                string primaryKeyValue = payload.PrimaryKeyValue;
                _configurationService.CloseTab(primaryKeyValue);
                _activeSubSystem = payload.Subsystem;
                _states          = ToolbarStates.None;
                DataPayLoad payLoad = new DataPayLoad
                {
                    PayloadType = DataPayLoad.Type.UpdateView
                };
                DeliverIncomingNotify(_activeSubSystem, payLoad);
                break;
            }

            case DataPayLoad.Type.UpdateView:
            {
                break;
            }

            // a subsystem has updated a new window with data.
            case DataPayLoad.Type.Insert:
            case DataPayLoad.Type.Update:
            {
                this.CurrentSaveImagePath = currentSaveImageModified;
                this.IsSaveEnabled        = true;
                // this keeps the value for saving.
                //MessageBox.Show("Schedule Payload");
                _careKeeper.Schedule(payload);

                break;
            }
            }
        }