コード例 #1
0
ファイル: DeleteTool.cs プロジェクト: thunder176/HeuristicLab
    protected override void OnActivateTool() {
      base.OnActivateTool();

      DeleteCommand cmd;

      if (this.Controller.Model.Selection.SelectedItems.Count > 0) {
        // If any one entity in the selction can't be deleted,
        // remove it from the selection.
        for (int i = 0; i < this.Controller.Model.Selection.SelectedItems.Count; i++) {
          IDiagramEntity entity = this.Controller.Model.Selection.SelectedItems[i];
          if (entity.AllowDelete == false) {
            this.Controller.Model.Selection.SelectedItems.Remove(entity);
            i--;
          }
        }
        cmd = new DeleteCommand(
                this.Controller,
               this.Controller.Model.Selection.SelectedItems.Copy());
        this.Controller.UndoManager.AddUndoCommand(cmd);

        // Alert each entity that they're about to be deleted.
        foreach (IDiagramEntity entity in this.Controller.Model.Selection.SelectedItems) {
          entity.OnBeforeDelete(cmd);
        }

        cmd.Redo();

        // Alert each entity that they have been deleted.
        foreach (IDiagramEntity entity in this.Controller.Model.Selection.SelectedItems) {
          entity.OnAfterDelete(cmd);
        }
      }

      DeactivateTool();
    }
コード例 #2
0
        public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer)
        {
            //this.persister = persister;
            //makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker));
            //showEdit = new RedirectToEditCommand(editUrlManager);
            //clone = new CloneCommand();
            //unpublishedDate = new EnsureNotPublishedCommand(); // moved to StateChanger
            //ensurePublishedDate = new EnsurePublishedCommand();  // moved to StateChanger

            this.security = security;
            
            save = new SaveCommand(persister);
            delete = new DeleteCommand(persister.Repository);

            replaceMaster = new ReplaceMasterCommand(versionMaker);
            makeVersion = new MakeVersionCommand(versionMaker);
            useDraftCmd = new UseDraftCommand(versionMaker);
            saveOnPageVersion = new SaveOnPageVersionCommand(versionMaker);

            draftState = new UpdateContentStateCommand(changer, ContentState.Draft);
            publishedState = new UpdateContentStateCommand(changer, ContentState.Published);

            updateObject = new UpdateObjectCommand();
            useMaster = new UseMasterCommand();
            validate = new ValidateCommand();
            saveActiveContent = new ActiveContentSaveCommand();
			moveToPosition = new MoveToPositionCommand();
			updateReferences = new UpdateReferencesCommand();
        }
コード例 #3
0
ファイル: CommandFactory.cs プロジェクト: navneetccna/n2cms
        public CommandFactory(IPersister persister, ISecurityManager security, IVersionManager versionMaker, IEditUrlManager editUrlManager, IContentAdapterProvider adapters, StateChanger changer)
        {
            this.persister = persister;
            makeVersionOfMaster = On.Master(new MakeVersionCommand(versionMaker));
            replaceMaster = new ReplaceMasterCommand(versionMaker);
            makeVersion = new MakeVersionCommand(versionMaker);
            useNewVersion = new UseNewVersionCommand(versionMaker);
            updateObject = new UpdateObjectCommand();
            delete = new DeleteCommand(persister.Repository);
            showPreview = new RedirectToPreviewCommand(adapters);
            showEdit = new RedirectToEditCommand(editUrlManager);
            useMaster = new UseMasterCommand();
            clone = new CloneCommand();
            validate = new ValidateCommand();
            this.security = security;
            save = new SaveCommand(persister);
            incrementVersionIndex = new IncrementVersionIndexCommand(versionMaker);
            draftState = new UpdateContentStateCommand(changer, ContentState.Draft);
            publishedState = new UpdateContentStateCommand(changer, ContentState.Published);
            saveActiveContent = new ActiveContentSaveCommand();
			moveToPosition = new MoveToPositionCommand();
			unpublishedDate = new EnsureNotPublishedCommand();
			publishedDate = new EnsurePublishedCommand();
			updateReferences = new UpdateReferencesCommand();
        }
コード例 #4
0
 public override void RaiseCanExecuteChanges()
 {
     base.RaiseCanExecuteChanges();
     EditCommand.RaiseCanExecuteChanged();
     CopyCommand.RaiseCanExecuteChanged();
     MoveCommand.RaiseCanExecuteChanged();
     NewFolderCommand.RaiseCanExecuteChanged();
     DeleteCommand.RaiseCanExecuteChanged();
 }
コード例 #5
0
        private async void Init(string ip)
        {
            await Load(null);

            QueryCommand.RaiseCanExecuteChanged();
            AddCommand.RaiseCanExecuteChanged();
            EditCommand.RaiseCanExecuteChanged();
            DeleteCommand.RaiseCanExecuteChanged();
        }
コード例 #6
0
ファイル: AddRemoveTests.cs プロジェクト: zdarovka/Sleet
        public async Task AddRemove_AddAndDeletePackagesAsync()
        {
            // Arrange
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                    {
                        var log        = new TestLogger();
                        var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root));
                        var settings   = new LocalSettings();

                        var context = new SleetContext()
                        {
                            Token          = CancellationToken.None,
                            LocalSettings  = settings,
                            Log            = log,
                            Source         = fileSystem,
                            SourceSettings = new FeedSettings()
                            {
                                CatalogEnabled = true
                            }
                        };

                        var testPackage1 = new TestNupkg("packageA", "1.0.0");
                        var testPackage2 = new TestNupkg("packageA", "2.0.0");
                        var testPackage3 = new TestNupkg("packageB", "2.0.0");

                        var zipFile1 = testPackage1.Save(packagesFolder.Root);
                        var zipFile2 = testPackage2.Save(packagesFolder.Root);
                        var zipFile3 = testPackage3.Save(packagesFolder.Root);

                        var toDelete = new List <PackageIdentity>()
                        {
                            new PackageIdentity("packageA", NuGetVersion.Parse("1.0.0")), new PackageIdentity("packageB", NuGetVersion.Parse("2.0.0"))
                        };

                        // Act
                        // run commands
                        await InitCommand.InitAsync(context);

                        await PushCommand.RunAsync(context.LocalSettings, context.Source, new List <string>() { packagesFolder.Root }, false, false, context.Log);

                        await DeleteCommand.DeletePackagesAsync(context.LocalSettings, context.Source, toDelete, string.Empty, false, context.Log);

                        var validateOutput = await ValidateCommand.RunAsync(context.LocalSettings, context.Source, context.Log);

                        // read outputs
                        var packageIndex  = new PackageIndex(context);
                        var indexPackages = await packageIndex.GetPackagesAsync();

                        // Assert
                        Assert.True(validateOutput);
                        Assert.Equal(1, indexPackages.Count);
                        Assert.Equal("packageA", indexPackages.First().Id);
                        Assert.Equal("2.0.0", indexPackages.First().Version.ToNormalizedString());
                    }
        }
コード例 #7
0
        private static void Main(string[] args)
        {
            iaso_v001Context context = new iaso_v001Context();

            ICommandRepository <Guid, Board> boardCommandRepo = new CommandRepository <Guid, Board>(context);

            IQueryRepository <Guid, Board> boardQueryRepo = new QueryRepository <Guid, Board>(context);

            IParameterisedQuery <int, Board> pQuery = new PQ();

            var b = pQuery.GetParameter();

            var boardList = boardQueryRepo.Items.ToList();

            foreach (var t in boardList.ToList())
            {
                Console.WriteLine(string.Format("{0} >>>> {1}", t.Id, t.Name));
            }

            var board = new Board
            {
                Id          = 1,
                Name        = "No Base 21/03",
                BoardTypeId = 1,
                CreateDate  = DateTime.Now,
                CreatedById = 1
            };


            ISaveCommand <Board> createCom = new CreateCommand <Guid, Board>()
            {
                Entity     = board,
                Repository = new CommandRepository <Guid, Board>(context)
            };

            var task = Task.Run(() => createCom.ExecuteAsync());

            task.Wait();

            try
            {
                IDeleteCommand <int> deleteCommand = new DeleteCommand <int, Board>()
                {
                    Repository = new CommandRepository <int, Board>(context)
                };

                deleteCommand.Id = 1;

                var tk = Task.Run(() => deleteCommand.ExecuteAsync());

                tk.Wait();
            }
            catch (Exception ex)
            {
            }
            Console.ReadKey();
        }
コード例 #8
0
 public Result Execute(DeleteCommand <TPrimaryKeyType> command)
 {
     if (Validate(command, _removeValidation).IsValid)
     {
         Repository.Remove(command.Id);
         Commit();
     }
     return(Return());
 }
コード例 #9
0
 public MainViewModel(ISettingsService settingsService, ITextToSpeechRepository textToSpeechRepository, IUnityContainer container)
 {
     this.container              = container;
     this.settingsService        = settingsService;
     settings                    = settingsService.settings;
     this.textToSpeechRepository = textToSpeechRepository;
     DeleteCmd                   = new DeleteCommand(this);
     createFolders();
 }
コード例 #10
0
        private void CreateDeleteCommand(Opcode type, bool noreply)
        {
            string        key = MemcachedEncoding.BinaryConverter.GetString(_rawData, 0, _requestHeader.KeyLength);
            DeleteCommand cmd = new DeleteCommand(type);

            cmd.Key     = key;
            cmd.NoReply = noreply;
            _command    = cmd;
        }
コード例 #11
0
 public override async Task <Result> Execute(DeleteCommand <TPrimaryKeyType> command)
 {
     if (Validate(command, _removeValidation).IsValid)
     {
         Repository.Remove(command.Id);
         await Commit();
     }
     return(await Return());
 }
コード例 #12
0
        public void Throw_When_No_Canvas_Exist()
        {
            var command = new DeleteCommand();

            command.Input = new string[] { "1", "1" };
            Action test = () => command.Execute(null);

            test.Should().Throw <ArgumentNullException>();
        }
コード例 #13
0
        public void Perform_DiscardsNewDataContainer()
        {
            var newOrder = _transaction.ExecuteInScope(() => Order.NewObject());
            var deleteNewOrderCommand = new DeleteCommand(_transaction, newOrder, _transactionEventSinkWithMock);

            deleteNewOrderCommand.Perform();

            Assert.That(_transaction.IsInvalid(newOrder.ID), Is.True);
        }
コード例 #14
0
        public async Task <APIResult> Delete([FromBody] DeleteCommand command)
        {
            var rs = await mediator.Send(command);

            return(new APIResult()
            {
                Result = rs
            });
        }
コード例 #15
0
        public void DeleteCommandShouldCallUndo()
        {
            DeleteCommand delete = new DeleteCommand(new Receiver());

            invoker.Commands.Add(delete);

            invoker.Execute();

            delete.Message.Should().BeEquivalentTo("Command Delete is cancelled.");
        }
コード例 #16
0
ファイル: NodeSystem.cs プロジェクト: NotYours180/ALLINONE
 public void Execute(DeleteCommand command)
 {
     if (InvertGraphEditor.Platform.MessageBox("Delete", "Delete Can't be Undo", "Go Ahead", "Cancel"))
     {
         foreach (var item in command.Item)
         {
             item.Repository.Remove(item);
         }
     }
 }
コード例 #17
0
 public void Specifying_invalid_noreply_value_will_result_in_error()
 {
     var stream = new MemoryStream();
     var cmd = new DeleteCommand();
     cmd.SetContext(stream);
     bool result = cmd.Init("a", "2", "bar");
     Assert.IsFalse(result);
     string actual = ReadAll(stream);
     Assert.AreEqual("CLIENT_ERROR Last argument was expected to be [noreply]\r\n", actual);
 }
コード例 #18
0
 private void raise()
 {
     OnPropertyChanged(() => Message);
     OnPropertyChanged(() => ReportTypesMessage);
     OnPropertyChanged(() => PossibleDesigners);
     OnPropertyChanged(() => ActiveDesigner);
     OnPropertyChanged(() => ScreenState);
     EditCommand.RaiseCanExecuteChanged();
     DeleteCommand.RaiseCanExecuteChanged();
 }
コード例 #19
0
        public override void SetUp()
        {
            base.SetUp();

            _transaction = new TestableClientTransaction();
            _order1      = (Order)LifetimeService.GetObject(_transaction, DomainObjectIDs.Order1, false);
            _transactionEventSinkWithMock = MockRepository.GenerateStrictMock <IClientTransactionEventSink>();

            _deleteOrder1Command = new DeleteCommand(_transaction, _order1, _transactionEventSinkWithMock);
        }
コード例 #20
0
        public void Execute_ShouldThrowArgumentException_WhenInvalidTypeIspassedForDeletion(string model)
        {
            var deleteCommand = new DeleteCommand(bookServiceMock.Object, movieServiceMock.Object, starServiceMock.Object, studioServiceMock.Object);
            var name          = "test";

            Assert.Throws <ArgumentException>(() => deleteCommand.Execute(new List <string>()
            {
                model, name
            }), $"{model}s cannot be deleted.");
        }
コード例 #21
0
ファイル: CqsMapper.cs プロジェクト: vladimirakimov/USERS
        public DeleteCommand Map(DeleteRequest request)
        {
            var id = new Guid(request.RouteId);

            var version = ToVersion(request.HeaderIfMatch);

            var result = new DeleteCommand(id, version);

            return(result);
        }
コード例 #22
0
        public void InvokeBothCommand()
        {
            CutCommand    cut    = new CutCommand(new Receiver());
            DeleteCommand delete = new DeleteCommand(new Receiver());

            invoker.Execute();

            cut.Message.Should().BeEquivalentTo("Command Cut is executed.");
            delete.Message.Should().BeEquivalentTo("Command Delete is cancelled.");
        }
コード例 #23
0
 private void ItemPropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (FindUnusedAndMissingCommand != null)
     {
         FindUnusedAndMissingCommand.RaiseCanExecuteChanged();
         SortCommand.RaiseCanExecuteChanged();
     }
     ViewComplexObjectsCommand?.RaiseCanExecuteChanged();
     DeleteCommand?.RaiseCanExecuteChanged();
 }
コード例 #24
0
        public FriendViewModel()
        {
            //Use this line with a singleton implementation of FriendCatalog
            //_friendCatalog = FriendCatalog.Instance;

            //use this i.e make an instance of FriendCatalog when using the non-singleton normal implementation of FriendCatalog
            _friendCatalog    = new FriendCatalog();
            AddContactCommand = new RelayCommand(AddFriend);
            _deletionCommand  = new DeleteCommand(_friendCatalog, this);
        }
コード例 #25
0
ファイル: MainViewModel.cs プロジェクト: kampee/zugab
        private void OnSelectedDetailedPersonChanged()
        {
            Notify("HasChanges");

            SaveCommand.RaiseCanExecuteChanged();
            DeleteCommand.RaiseCanExecuteChanged();
            RevertCommand.RaiseCanExecuteChanged();

            SelectedDetailedPerson?.CheckDocuments();
        }
コード例 #26
0
ファイル: CodeBlock.cs プロジェクト: orb1t/StructuredEditor
 private void Init()
 {
     CanMoveUpDown = true;
     Draggable     = true;
     if (Menu == null)
     {
         Menu = DeleteCommand.CreateDeleteMenu(this);
     }
     this.HMembers.MyListControl.Box.Padding.Bottom = 3;
 }
コード例 #27
0
        public int delete_contact(DBColumn search_column, string key)
        {
            var delete = new DeleteCommand(configuration, null);

            delete.Where = new BinaryExpression(new ColumnExpression(search_column), new ConstantExpression(key, search_column), BinaryOperationType.Equal);
            ContactListTransaction transaction = new ContactListTransaction();

            transaction.Add(delete);
            return(configuration.RunTransaction(transaction));
        }
コード例 #28
0
 private PropValueData[] GetAdditionalProps(DeleteCommand delete)
 {
     return(SyncEmailUtils.GetMessageProps(new SyncEmailContext
     {
         SyncMessageId = delete.ServerId
     }, this.UserSmtpAddressString, base.EntryId, new PropValueData[]
     {
         new PropValueData(PropTag.ObjectType, 1)
     }));
 }
コード例 #29
0
 public void Specifying_invalid_time_value_will_result_in_error()
 {
     var stream = new MemoryStream();
     var cmd = new DeleteCommand();
     cmd.SetContext(stream);
     bool result = cmd.Init("b", "?x");
     Assert.IsFalse(result);
     string actual = ReadAll(stream);
     Assert.AreEqual("CLIENT_ERROR Exptime should be an integer\r\n", actual);
 }
コード例 #30
0
        protected override void OnChanged()
        {
            base.OnChanged();

            // Refresh commands
            SaveCommand.RaiseCanExecuteChanged();
            SaveAndCloseCommand.RaiseCanExecuteChanged();
            CancelCommand.RaiseCanExecuteChanged();
            DeleteCommand.RaiseCanExecuteChanged();
        }
コード例 #31
0
 public void Specifying_too_many_arguments_will_result_in_error()
 {
     var stream = new MemoryStream();
     var cmd = new DeleteCommand();
     cmd.SetContext(stream);
     bool result = cmd.Init("a", "2", "noreply", "bar");
     Assert.IsFalse(result);
     string actual = ReadAll(stream);
     Assert.AreEqual("CLIENT_ERROR Expected 'delete <key> [<time>] [noreply]'\r\n", actual);
 }
コード例 #32
0
        public void SparqlUpdateDeleteWithCommand()
        {
            String                 command = "WITH <http://example.org/> DELETE { ?s ?p ?o } WHERE {?s ?p ?o}";
            SparqlUpdateParser     parser  = new SparqlUpdateParser();
            SparqlUpdateCommandSet cmds    = parser.ParseFromString(command);

            DeleteCommand delete = (DeleteCommand)cmds[0];

            Assert.AreEqual(new Uri("http://example.org/"), delete.GraphUri, "Graph URI of the Command should be equal to http://example.org/");
        }
コード例 #33
0
        /// <summary>
        /// I constructoren sker tre ting.
        /// 1) Vi sætter samlingerne af Commands hørende til hver tilstand af viewet op.
        /// 2) Vi sikrer os at blive orienteret, npr viewet skifter tilstand.
        /// 3) Vi sætter viewet til at starte i Read/Delete-tilstanden.
        /// </summary>
        public PageViewModelAppBase()
        {
            // Command-objekter for Delete, Create og Update
            CommandBase deleteCmd = new DeleteCommand <T, TDataViewModel>(_catalog, this);
            CommandBase createCmd = new CreateCommand <T, TDataViewModel>(_catalog, this);
            CommandBase updateCmd = new UpdateCommand <T, TDataViewModel>(_catalog, this);

            // Command-objekter for at skifte til en specifik view-tilstand
            CommandBase setReadDeleteViewStateCmd = new SetViewStateCommand <TDataViewModel>(this, PageViewModelState.ReadDelete);
            CommandBase setCreateViewStateCmd     = new SetViewStateCommand <TDataViewModel>(this, PageViewModelState.Create);
            CommandBase setUpdateViewStateCmd     = new SetViewStateCommand <TDataViewModel>(this, PageViewModelState.Update);

            // I Read/Delete-tilstand er tre Commands til rådighed:
            // Create...: Skift til Create-tilstanden
            // Update...: Skift til Update-tilstanden
            // Delete : Slet det objekt, som p.t. er udvalgt.
            Dictionary <string, CommandBase> readDeleteCommands = new Dictionary <string, CommandBase>();

            readDeleteCommands.Add("Create...", setCreateViewStateCmd);
            readDeleteCommands.Add("Update...", setUpdateViewStateCmd);
            readDeleteCommands.Add("Delete", deleteCmd);

            // I Create-tilstand er tre Commands til rådighed:
            // Read/Delete...: Skift til Read/Delete-tilstanden
            // New: Lav et nyt, tomt objekt, som ikke er indsat i databasen endnu.
            // Save: Indsæt objektet i databasen.
            Dictionary <string, CommandBase> createCommands = new Dictionary <string, CommandBase>();

            createCommands.Add("Read/Delete...", setReadDeleteViewStateCmd);
            createCommands.Add("New", setCreateViewStateCmd);
            createCommands.Add("Save", createCmd);

            // I Update-tilstand er tre Commands til rådighed:
            // Read/Delete...: Skift til Read/Delete-tilstanden
            // Create...: Skift til Create-tilstanden
            // Update: Opdater databasen med de udførte ændringer til det udvalgte objekt.
            Dictionary <string, CommandBase> updateCommands = new Dictionary <string, CommandBase>();

            updateCommands.Add("Read/Delete...", setReadDeleteViewStateCmd);
            updateCommands.Add("Create...", setCreateViewStateCmd);
            updateCommands.Add("Update", updateCmd);

            // Lav den endelige samling af Commands hørende til hver tilstand
            _allCommands = new Dictionary <PageViewModelState, Dictionary <string, CommandBase> >();
            _allCommands.Add(PageViewModelState.ReadDelete, readDeleteCommands);
            _allCommands.Add(PageViewModelState.Create, createCommands);
            _allCommands.Add(PageViewModelState.Update, updateCommands);

            // Hook OnViewStateHasChanged op til at blive kalde,
            // når tilstanden af viewet ændres.
            _viewStateChanged += OnViewStateHasChanged;

            // Start viewet i read/Delete-tilstanden.
            SetState(PageViewModelState.ReadDelete);
        }
コード例 #34
0
        public async Task BadgeFile_VerifyBadgesUpdatedAfterDeleteAll()
        {
            // Arrange
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                    {
                        var log        = new TestLogger();
                        var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root));
                        var settings   = new LocalSettings();

                        var context = new SleetContext()
                        {
                            Token          = CancellationToken.None,
                            LocalSettings  = settings,
                            Log            = log,
                            Source         = fileSystem,
                            SourceSettings = new FeedSettings()
                            {
                                BadgesEnabled = true
                            }
                        };

                        // Initial packages
                        var identities = new HashSet <PackageIdentity>()
                        {
                            new PackageIdentity("a", NuGetVersion.Parse("2.0.0"))
                        };

                        foreach (var id in identities)
                        {
                            var testPackage = new TestNupkg(id.Id, id.Version.ToFullString());
                            var zipFile     = testPackage.Save(packagesFolder.Root);
                        }

                        // Push
                        await InitCommand.InitAsync(context);

                        await PushCommand.RunAsync(context.LocalSettings, context.Source, new List <string>() { packagesFolder.Root }, false, false, context.Log);

                        // Remove
                        await DeleteCommand.RunAsync(context.LocalSettings, context.Source, "a", "2.0.0", "test", true, context.Log);

                        // Validate
                        var validateOutput = await ValidateCommand.RunAsync(context.LocalSettings, context.Source, context.Log);

                        validateOutput.Should().BeTrue();

                        // read output
                        var stablePath = Path.Combine(target.Root, "badges/v/a.svg");
                        var prePath    = Path.Combine(target.Root, "badges/vpre/a.svg");
                        File.Exists(stablePath).Should().BeFalse();
                        File.Exists(prePath).Should().BeFalse();
                    }
        }
コード例 #35
0
        public RepeatableFlexPageViewModel(INavigationService navigationService, IPageDialogService pageDlg)
        {
            FlexDirection.Value   = Xamarin.Forms.FlexDirection.Row;
            FlexAlignItems.Value  = Xamarin.Forms.FlexAlignItems.Start;
            FlexJustify.Value     = Xamarin.Forms.FlexJustify.Start;
            FlexWrap.Value        = Xamarin.Forms.FlexWrap.NoWrap;
            ScrollDirection.Value = ScrollOrientation.Horizontal;

            SetColors(DirectionColor, 0);
            SetColors(AColor, 3);
            SetColors(JColor, 3);
            SetColors(WrapColor, 0);

            DirectionCommand.Subscribe(x => {
                var idx             = int.Parse(x);
                FlexDirection.Value = (Xamarin.Forms.FlexDirection)idx;
                SetScrollDirection();
                SetColors(DirectionColor, idx);
            });
            AlignItemsCommand.Subscribe(x => {
                var idx = int.Parse(x);
                FlexAlignItems.Value = (Xamarin.Forms.FlexAlignItems)idx;
                SetColors(AColor, idx);
            });
            JustifyContentCommand.Subscribe(x => {
                var idx           = int.Parse(x);
                FlexJustify.Value = (Xamarin.Forms.FlexJustify)idx;
                SetColors(JColor, idx);
            });
            WrapCommand.Subscribe(x => {
                var idx        = int.Parse(x);
                FlexWrap.Value = (Xamarin.Forms.FlexWrap)idx;
                SetScrollDirection();
                SetColors(WrapColor, idx);
            });


            BoxList = new ObservableCollection <Hoge>(Shuffle());

            AddCommand.Subscribe(_ => {
                BoxList.Add(GetNextItem());
            });

            DeleteCommand.Subscribe(_ => {
                BoxList.Remove(BoxList.Last());
            });

            ReplaceCommand.Subscribe(__ => {
                BoxList[0] = GetNextItem();
            });

            ClearCommand.Subscribe(__ => {
                BoxList.Clear();
            });
        }
コード例 #36
0
 private void InvalidateCommands()
 {
     SaveCommand.RaiseCanExecuteChanged();
     DeleteCommand.RaiseCanExecuteChanged();
     CancelCommand.RaiseCanExecuteChanged();
     PrintCommand.RaiseCanExecuteChanged();
     GetAccountCommand.RaiseCanExecuteChanged();
     EditOrderItemCommand.RaiseCanExecuteChanged();
     DeleteOrderItemCommand.RaiseCanExecuteChanged();
     NewOrderItemCommand.RaiseCanExecuteChanged();
 }
コード例 #37
0
        public void ShouldDeleteFile()
        {
            // Given
            Assert.IsTrue (File.Exists (FileToDelete));

            // When
            var command = new DeleteCommand (FileToDelete);
            command.Execute ();

            // Then
            Assert.IsFalse(File.Exists(FileToDelete));
        }
コード例 #38
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="provider">The provider.</param>
        public CustomerViewModel(IProvider provider)
        {
            _provider = provider;

            Customers = new ObservableCollection<CustomerModel>();

            AddCommandModel = new AddCommand(this);
            EditCommandModel = new EditCommand(this);
            DeleteCommandModel = new DeleteCommand(this);

            Index = -1;
        }
コード例 #39
0
        public void ShouldRollbackFileDeletion()
        {
            // Given
            var command = new DeleteCommand (FileToDelete);
            command.Execute ();

            // When
            command.Rollback ();

            // Then
            Assert.IsTrue(File.Exists(FileToDelete));
        }
コード例 #40
0
        public void ShouldReturnFileContent()
        {
            // Given
            File.WriteAllText (FileToDelete, "Hello World!");
            var command = new DeleteCommand (FileToDelete);
            command.Execute ();

            // When
            command.Rollback ();

            // Then
            Assert.AreEqual ("Hello World!", File.ReadAllText (FileToDelete));
        }
コード例 #41
0
        public void When_deleting_item_in_cache_will_remove_from_cache()
        {
            Cache["foo"] = new CachedItem();

            var command = new DeleteCommand();
            command.SetContext(new MemoryStream());
            command.Init("foo");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            var cachedItem = (CachedItem)Cache.Get("foo");
            Assert.IsNull(cachedItem);
        }
コード例 #42
0
        public void DeleteEntity_ShouldDeleteEntity()
        {
            // arrange
            var eventUid = Guid.NewGuid();
            var ev = new D2DEvent {Uid = eventUid};
            var stub = new FakeRepository(new Dictionary<Type, IEnumerable<IEntity>>
            {
                {typeof (D2DEvent), new[] {ev}}
            });
            var deleteCommand = new DeleteCommand<D2DEvent> {Uid = eventUid};

            // act
            deleteCommand.Execute(stub);

            // assert
            Assert.AreEqual(1, stub.RemoveCalls.Count());
            Assert.AreEqual(eventUid, stub.RemoveCalls.Single().Uid);
        }
コード例 #43
0
ファイル: SqlFormatter.cs プロジェクト: firestrand/IQToolkit
 protected override Expression VisitDelete(DeleteCommand delete)
 {
     this.Write("DELETE FROM ");
     bool saveHideTable = this.HideTableAliases;
     bool saveHideColumn = this.HideColumnAliases;
     this.HideTableAliases = true;
     this.HideColumnAliases = true;
     this.VisitSource(delete.Table);
     if (delete.Where != null)
     {
         this.WriteLine(Indentation.Same);
         this.Write("WHERE ");
         this.VisitPredicate(delete.Where);
     }
     this.HideTableAliases = saveHideTable;
     this.HideColumnAliases = saveHideColumn;
     return delete;
 }
コード例 #44
0
 protected virtual Expression VisitDelete(DeleteCommand delete)
 {
     var table = (TableExpression)this.Visit(delete.Table);
     var where = this.Visit(delete.Where);
     return this.UpdateDelete(delete, table, where);
 }
コード例 #45
0
 protected DeleteCommand UpdateDelete(DeleteCommand delete, TableExpression table, Expression where)
 {
     if (table != delete.Table || where != delete.Where)
     {
         return new DeleteCommand(table, where);
     }
     return delete;
 }
コード例 #46
0
		private bool CompareDelete(DeleteCommand x, DeleteCommand y)
		{
			return this.Compare(x.Table, y.Table) && this.Compare(x.Where, y.Where);
		}
コード例 #47
0
 public void When_time_is_zero_will_parse_as_if_null()
 {
     var cmd = new DeleteCommand();
     cmd.SetContext(new MemoryStream());
     bool result = cmd.Init("foo", "0");
     Assert.IsTrue(result);
     Assert.AreEqual("foo", cmd.Key);
     Assert.IsFalse(cmd.NoReply);
     Assert.IsNull(cmd.BlockedFromUpdatingUntil);
 }
コード例 #48
0
 public void Will_parse_key_and_time_args()
 {
     SystemTime.Now = () => new DateTime(2000,1,1);
     var cmd = new DeleteCommand();
     cmd.SetContext(new MemoryStream());
     bool result = cmd.Init("foo", "60");
     Assert.IsTrue(result);
     Assert.AreEqual("foo", cmd.Key);
     Assert.IsFalse(cmd.NoReply);
     Assert.AreEqual(new DateTime(2000, 1, 1, 0, 1, 0), cmd.BlockedFromUpdatingUntil);
 }
コード例 #49
0
        private static Message Convert(string exchangeCode, DeleteCommand deleteCommand)
        {
            List<Transaction> transactionList = new List<Transaction>();
            List<Order> orderList = new List<Order>();
            List<OrderRelation> orderRelationList = new List<OrderRelation>();

            XmlNode transactionNodes = deleteCommand.Content["AffectedOrders"];
            if (transactionNodes != null)
            {
                foreach (XmlNode transactionNode in transactionNodes.ChildNodes)
                {
                    Transaction[] transactions;
                    Order[] orders;
                    OrderRelation[] orderRelations;

                    CommandConvertor.Parse(exchangeCode,transactionNode, out transactions, out orders, out orderRelations);
                    transactionList.AddRange(transactions);
                    orderList.AddRange(orders);
                    orderRelationList.AddRange(orderRelations);
                }
            }

            Guid deletedOrderId = Guid.Empty;
            Guid accountId = Guid.Empty;
            Guid instrumentId = Guid.Empty;
            XmlNode deletedOrderNode = deleteCommand.Content["DeletedOrder"];
            if (deletedOrderNode != null)
            {
                deletedOrderId = new Guid(deletedOrderNode.Attributes["ID"].Value);
                instrumentId = new Guid(deletedOrderNode.Attributes["InstrumentID"].Value);
                accountId = new Guid(deletedOrderNode.Attributes["AccountID"].Value);
            }

            DeleteMessage deleteMessage = new DeleteMessage(exchangeCode,deletedOrderId,instrumentId,
                transactionList.ToArray(), orderList.ToArray(), orderRelationList.ToArray());
            return  deleteMessage;
        }
コード例 #50
0
 protected virtual bool CompareDelete(DeleteCommand x, DeleteCommand y)
 {
     return this.Compare(x.Table, y.Table) && this.Compare(x.Where, y.Where);
 }
コード例 #51
0
 public void When_noreply_is_specified_NoReply_equal_to_true()
 {
     var cmd = new DeleteCommand();
     cmd.SetContext(new MemoryStream());
     bool result = cmd.Init("foo", "0", "noreply");
     Assert.IsTrue(result);
     Assert.AreEqual("foo", cmd.Key);
     Assert.IsTrue(cmd.NoReply);
     Assert.IsNull(cmd.BlockedFromUpdatingUntil);
 }
コード例 #52
0
        public void When_deleting_item_in_cache_with_time_will_block_replace_operations()
        {
            Cache["foo2"] = new CachedItem();

            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("DELETED\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };
            stream = GetStreamWithData(buffer);
            var replaceCommand = new ReplaceCommand();
            replaceCommand.SetContext(stream);
            replaceCommand.Init("foo2", "1", "6000", "4");

            replaceCommand.FinishedExecuting += () => wait.Set();
            replaceCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_STORED\r\n", ReadAll(6, stream));
        }
コード例 #53
0
        public void When_deleting_item_not_in_cache_will_return_nothing_with_no_reply()
        {
            Cache["foo"] = new CachedItem();

            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo2", "0", "noreply");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("", ReadAll(stream));
        }
コード例 #54
0
        public void When_deleting_item_in_cache_will_return_deleted()
        {
            Cache["foo"] = new CachedItem();

            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("DELETED\r\n", ReadAll(stream));
        }
コード例 #55
0
        private void DeletedCommandBtn_Click(object sender, RoutedEventArgs e)
        {
            if (DeletedIndex > 7) return;
            string xmlPath = string.Empty;
            ComboBoxItem item = (ComboBoxItem)this.DeleteOrderTypeCmb.SelectedItem;
            string seletName = item.Content.ToString();
            switch (seletName)
            {
                case "Open":
                    xmlPath = this.GetCommandXmlPath("Deleted_Open");
                    break;
                case "Close":
                    xmlPath = this.GetCommandXmlPath("Deleted_Close");
                    break;
            }
            XmlDocument doc = new XmlDocument();
            doc.Load(xmlPath);
            XmlNode orderxml = doc.ChildNodes[1].ChildNodes[0];
            XmlNode xmlAccount = doc.ChildNodes[1].ChildNodes[1];

            DeleteCommand deletedCommand;
            deletedCommand = new DeleteCommand(DeletedIndex);
            deletedCommand.InstrumentID = XmlConvert.ToGuid(orderxml.Attributes["InstrumentID"].Value);
            deletedCommand.AccountID = XmlConvert.ToGuid(orderxml.Attributes["AccountID"].Value);

            XmlDocument xmlDoc = new XmlDocument();
            XmlNode content = xmlDoc.CreateElement("Delete");
            xmlDoc.AppendChild(content);
            deletedCommand.Content = content;

            content.AppendChild(xmlDoc.ImportNode(orderxml, true));
            content.AppendChild(xmlDoc.ImportNode(xmlAccount, true));

            ManagerClient.AddCommand(deletedCommand);
            DeletedIndex++;
        }
コード例 #56
0
ファイル: DbExpressionVisitor.cs プロジェクト: CMONO/elinq
 protected DeleteCommand UpdateDelete(DeleteCommand delete, TableExpression table, Expression where)
 {
     if (table != delete.Table || where != delete.Where)
     {
         return new DeleteCommand(table, where,delete.Instance, delete.SupportsVersionCheck);
     }
     return delete;
 }
コード例 #57
0
ファイル: BaseStringSQLVisitor.cs プロジェクト: npenin/uss
		public abstract void Visit(DeleteCommand deleteCommand);
コード例 #58
0
 public void Will_parse_key_only_args()
 {
     var cmd = new DeleteCommand();
     cmd.SetContext(new MemoryStream());
     bool result = cmd.Init("foo");
     Assert.IsTrue(result);
     Assert.AreEqual("foo", cmd.Key);
     Assert.IsFalse(cmd.NoReply);
     Assert.IsNull(cmd.BlockedFromUpdatingUntil);
 }
コード例 #59
0
ファイル: MainWindow.cs プロジェクト: mono/monohotdraw
 protected virtual void OnDeleteActivated(object sender, System.EventArgs e)
 {
     ICommand command = new DeleteCommand ("Delete command", this);
     if (command.IsExecutable == true) {
         command.Execute ();
     } else {
         MessageDialog dialog = new MessageDialog (this, DialogFlags.DestroyWithParent,
             MessageType.Error, ButtonsType.Close, "Select figures to delete.");
         dialog.Run ();
         dialog.Destroy ();
     }
 }
コード例 #60
0
        public void When_deleting_item_in_cache_with_time_when_item_do_not_exists_should_not_block_add_operations()
        {
            var stream = new MemoryStream();
            var command = new DeleteCommand();
            command.SetContext(stream);
            command.Init("foo2", "500");

            command.FinishedExecuting += () => wait.Set();
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("NOT_FOUND\r\n", ReadAll(stream));

            wait.Reset();

            var buffer = new byte[] { 1, 2, 3, 4 };
            stream = GetStreamWithData(buffer);
            var addCommand = new AddCommand();
            addCommand.SetContext(stream);
            addCommand.Init("foo2", "1", "6000", "4");

            addCommand.FinishedExecuting += () => wait.Set();
            addCommand.Execute();
            wait.WaitOne();

            Assert.AreEqual("STORED\r\n", ReadAll(6, stream));
        }