public void SomeFoo()
    {
        //use of unassigned variable here: obj
        BasicCommand obj = new BasicCommand((o) => SomeOtherFoo(o.Parameter1));

        obj.Execute();
    }
 public RepoUCViewModel(USCurrencyRepo _repo) : base(_repo)
 {
     AddCommand  = new BasicCommand(ExecuteCommandAdd, CanExecuteCommandAdd);
     LoadCommand = new BasicCommand(ExecuteCommandLoad, CanExecuteCommandLoad);
     NewCommand  = new BasicCommand(ExecuteCommandNew, CanExecuteCommandNew);
     UpdateTotal();
 }
Пример #3
0
        /// <summary>
        /// This constructor provides the option of making the ProgressDialog modal.
        /// </summary>
        /// <param name="parentForm">The parent, or owning form for the ProgressDialog</param>
        /// <param name="command">The AsyncCommand c</param>
        /// <param name="progressTitleText">The title to use on the ProgressDialog</param>
        /// <param name="showModally">true if you want to use this modally, false otherwise. If you pass true, you must use ShowModal later to show the ProgressDialog</param>
        public ProgressDialogHandler(Form parentForm, BasicCommand command, string progressTitleText, bool showModally)
        {
            _parentForm                         = parentForm;
            _currentCommand                     = command;
            command.InitializeCallback          = InitializeProgress;
            command.ProgressCallback            = UpdateProgress;
            command.PrimaryStatusTextCallback   = UpdateStatus1;
            command.SecondaryStatusTextCallback = UpdateOverview;

            _currentCommand.BeginCancel    += OnCommand_BeginCancel;
            _currentCommand.EnabledChanged += OnCommand_EnabledChanged;
            _currentCommand.Error          += OnCommand_Error;
            _currentCommand.Finish         += OnCommand_Finish;

            _progressDialog = new ProgressDialog
            {
                Text = progressTitleText
            };
            _progressDialog.CancelRequested += _progressDialog_Cancelled;
            _progressDialog.Owner            = parentForm;
            _progressDialog.CanCancel        = true;
            //To use this progress in a modal way you need to call ShowModal after you have setup the ProgressDialogState
            if (!showModally)
            {
                //if it is not modal then we can show the dialog and it won't inhibit the rest of the setup and calling.
                _progressDialog.Show();
            }
        }
Пример #4
0
        public EurekaServiceViewModel(AppBrowserViewModel appBrowserViewModel, EurekaService service)
        {
            this.appBrowserViewModel = appBrowserViewModel;
            this.service             = service;

            appMapper = new ObservableCollectionMapper <Tuple <EurekaApplication, EurekaApplicationInstance>, EurekaApplicationViewModel>(
                tuple => new EurekaApplicationViewModel(tuple.Item1, tuple.Item2),
                viewModel => Tuple.Create(viewModel.Application, viewModel.Instance),
                (tuple, viewModel) => viewModel.Update(),
                (viewModel1, viewModel2) =>
            {
                int r = string.CompareOrdinal(viewModel1.AppName, viewModel2.AppName);
                if (r == 0)
                {
                    r = string.CompareOrdinal(viewModel1.HostName, viewModel2.HostName);
                }
                if (r == 0)
                {
                    r = string.CompareOrdinal(viewModel1.InstanceId, viewModel2.InstanceId);
                }
                return(r);
            }
                );

            ConnectCommand                = new BasicCommand(() => !service.Connected, o => service.Connect());
            DisconnectCommand             = new BasicCommand(() => service.Connected, o => service.Disconnect());
            RefreshCommand                = new BasicCommand(() => service.Connected, o => service.RefreshApplications());
            DeregisterApplicationsCommand = new BasicCommand(() => service.Connected && SelectedApplications.Count > 0, o => DeregisterApplications());

            SelectedApplications.CollectionChanged += (sender, args) => { DeregisterApplicationsCommand.UpdateState(); };
            service.StateChanged += () => appBrowserViewModel.ViewContext.Invoke(Update);

            Update();
        }
        public ManageComponenteViewModel()
        {
            Stari = new ObservableCollection <string>();
            Stari.Add("Toate");
            foreach (var stare in Enum.GetValues(typeof(StareCerere)))
            {
                Stari.Add(stare.ToString());
            }
            SelectedStareComponenta = Stari[0];

            Tipuri = new ObservableCollection <string>();
            Tipuri.Add("Toate");
            foreach (var tip in Enum.GetValues(typeof(TipComponenta)))
            {
                Tipuri.Add(tip.ToString());
            }
            SelectedTipComponenta = Tipuri[0];

            LoadComponenteCommand        = new BasicCommand(LoadData);
            DeleteDonatieCommand         = new BasicCommand(DeleteComponenta);
            UpdateCommand                = new BasicCommand(UpdateComponenta);
            DeservireComponentaCommand   = new BasicCommand(DeservireComponenta);
            FilterComponenteCommand      = new BasicCommand(FilterComponente);
            ClearFilterComponenteCommand = new BasicCommand(ClearFilterComponente);
        }
        public DockerImageListViewModel(AppBrowserViewModel appBrowserViewModel, DockerService service)
        {
            this.appBrowserViewModel = appBrowserViewModel;
            this.service             = service;
            ModuleName = "Images";

            imagesMapper = new ObservableCollectionMapper <DockerImage, DockerImageViewModel>(
                image => new DockerImageViewModel(service, image),
                viewModel => viewModel.Image,
                (image, viewModel) => viewModel.Update(),
                (viewModel1, viewModel2) =>
            {
                int r = string.CompareOrdinal(viewModel1.RepoTagsAsText, viewModel2.RepoTagsAsText);
                if (r == 0)
                {
                    r = string.CompareOrdinal(viewModel1.RepoDigestsAsText, viewModel2.RepoDigestsAsText);
                }
                if (r == 0)
                {
                    r = string.CompareOrdinal(viewModel1.Id, viewModel2.Id);
                }
                return(r);
            }
                );

            RefreshCommand      = new BasicCommand(() => service.Connected, o => service.Refresh());
            DeleteImagesCommand = new BasicCommand(() => service.Connected && SelectedImages.Count > 0, o => DeleteImages());

            SelectedImages.CollectionChanged += (sender, args) => { DeleteImagesCommand.UpdateState(); };

            service.StageChanged += () => appBrowserViewModel.ViewContext.Invoke(Update);

            Update();
        }
Пример #7
0
        public async Task ScheduleAsync_SkipSchedulesThatAlreadyExists()
        {
            // Arrange
            var name              = BaseValueGenerator.Word();
            var queueName         = Default.Queue;
            var cron              = Cron.Weekly();
            var payload           = Guid.NewGuid().ToByteArray();
            var command           = new BasicCommand();
            var cancellationToken = CancellationToken.None;
            var existingItem      = new ScheduleItem
            {
                CronExpression = cron.Expression,
                Name           = name,
                Payload        = payload,
                Queue          = queueName
            };

            _payloadSerializer.SerializeAsync(command, cancellationToken).Returns(Task.FromResult(payload));
            _payloadProtector.ProtectAsync(payload, cancellationToken).Returns(Task.FromResult(payload));
            _scheduleProviderFactory.CreateAsync(queueName, cancellationToken).Returns(Task.FromResult(_scheduleProvider));
            _scheduleProvider.LoadByNameAsync(name, cancellationToken).Returns(Task.FromResult(existingItem));

            // Act
            await _sut.ScheduleAsync(name, command, cron, cancellationToken);

            // Assert
            await _scheduleProvider.DidNotReceiveWithAnyArgs().CreateAsync(default(ScheduleItem), cancellationToken);
        }
Пример #8
0
 public void EnqueueCommand(BasicCommand cmd)
 {
     if (cmd != null)
     {
         commandQueue.Enqueue(cmd);
     }
 }
        public async Task CommandPipeline_Unauthorised_ReturnsForbidden()
        {
            // Arrange
            var testCommand = new BasicCommand(123, "fail-auth");
            var client      = this.Factory.CreateClient();

            // Act
            var body = new StringContent(
                JsonConvert.SerializeObject(
                    new { command = "TEST/BasicCommand", body = testCommand }),
                System.Text.Encoding.UTF8,
                "application/json");

            var response = await client.PostAsync("/command", body);

            // Assert
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
            Assert.Throws <HttpRequestException>(
                () => response.EnsureSuccessStatusCode());

            var tracker        = this.Factory.Services.GetRequiredService <ICommandTrackingStore>();
            var trackedCommand = tracker.Get <BasicCommand>();

            Assert.NotNull(trackedCommand);

            Assert.Equal(typeof(BasicCommand), trackedCommand.CommandType);
            Assert.Equal(testCommand.ToJson(), trackedCommand.CommandJson);

            Assert.True(trackedCommand.Authorized);
            Assert.False(trackedCommand.Validated);
            Assert.False(trackedCommand.Handled);
        }
Пример #10
0
        public void Then_ShouldAddCommandsToDictionaryInOrder()
        {
            // Arrange
            var workflow = new WorkflowCommand();
            var command1 = new BasicCommand();
            var command2 = new BasicCommand();
            var command3 = new BasicCommand();
            var command4 = new BasicCommand();
            var command5 = new BasicCommand();
            var command6 = new BasicCommand();

            // Act
            workflow.Then(i => command1)
            .Then(i => new[]
            {
                command2,
                command3
            })
            .Then(i => new[]
            {
                command4,
                command5,
                command6
            });

            // Assert
            workflow.Entries.Should().HaveCount(3);
            workflow.Entries.Where(x => x.Key == 0).SelectMany(x => x.Value).Should().ContainInOrder(command1);
            workflow.Entries.Where(x => x.Key == 1).SelectMany(x => x.Value).Should().ContainInOrder(command2, command3);
            workflow.Entries.Where(x => x.Key == 2).SelectMany(x => x.Value).Should().ContainInOrder(command4, command5, command6);
        }
Пример #11
0
        public bool IsBranchEmpty()
        {
            BasicCommand main = Commands[CommandIndex];
            BasicCommand next = Commands[CommandIndex + 1];

            return(next.Indent <= main.Indent);
        }
        public PacientDetailsViewModel(PacientViewModel pacientViewModel)
        {
            Pacient = new PacientViewModel();
            if (pacientViewModel.Id != 0)
            {
                Pacient.Id                   = pacientViewModel.Id;
                Pacient.GrupaDeSange         = pacientViewModel.GrupaDeSange;
                Pacient.DataNastere          = pacientViewModel.DataNastere;
                Pacient.IdGrupaDeSange       = pacientViewModel.IdGrupaDeSange;
                Pacient.InstitutieAsociata   = pacientViewModel.InstitutieAsociata;
                Pacient.IdInstitutieAsociata = pacientViewModel.IdInstitutieAsociata;
                Pacient.Nume                 = pacientViewModel.Nume;
                Pacient.Prenume              = pacientViewModel.Prenume;
            }
            GrupeDeSange       = new ObservableCollection <GrupaDeSange>(AppService.Instance.GrupaDeSangeService.GetAll());
            InstitutiiAsociate = new ObservableCollection <InstitutieAsociata>(AppService.Instance.InstitutieAsociataService.GetAll());
            if (pacientViewModel.Id == 0)
            {
                SelectedGrupa      = GrupeDeSange[0];
                SelectedInstitutie = InstitutiiAsociate[0];
            }
            else
            {
                SelectedInstitutie = Pacient.InstitutieAsociata;
                SelectedGrupa      = Pacient.GrupaDeSange;
            }

            SalveazaCommand = new BasicCommand(Salveaza);
        }
Пример #13
0
        private void ExecuteBasicCommand(BasicCommand command)
        {
            int a, b;

            switch (command)
            {
            case BasicCommand.Add:
                b = IntStack.Pop();
                a = IntStack.Pop();
                IntStack.Push(a + b);
                break;

            case BasicCommand.Divide:
                b = IntStack.Pop();
                a = IntStack.Pop();
                if (b == 0)
                {
                    IntStack.Push(0);
                }
                IntStack.Push(a / b);
                break;

            case BasicCommand.Multiply:
                b = IntStack.Pop();
                a = IntStack.Pop();
                IntStack.Push(a * b);
                break;

            case BasicCommand.Subtract:
                b = IntStack.Pop();
                a = IntStack.Pop();
                IntStack.Push(a - b);
                break;
            }
        }
 public ViewDesigns()
 {
     Navigator   = Navigator.Instance;
     Rooms       = LoadRooms();
     EditCommand = new ArgumentCommand <Design>(
         design => {
         Navigator.Push(new DesignEditorView(design));
         ;
     }
         );
     DeleteCommand    = new ArgumentCommand <Design>(DeleteDesign);
     CancelCommand    = new BasicCommand(ClosePopup);
     AddDesignCommand = new BasicCommand(AddDesign);
     ReloadCommand    = new BasicCommand(Reload);
     OpenPopup        = new BasicCommand(
         () => {
         IsAdding = true;
         OnPropertyChanged();
     }
         );
     //Om te voorkomen dat unit tests falen
     if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
     {
         RenderDesigns();
         MessageQueue = new SnackbarMessageQueue();
     }
 }
Пример #15
0
        public MainViewModel(IEnumerable <IModelReaderAsync> readers,
                             IEnumerable <IModelWriterAsync> writers)
        {
            if (!readers.Any())
            {
                throw new ArgumentException(nameof(readers));
            }

            if (!writers.Any())
            {
                throw new ArgumentException(nameof(writers));
            }

            _readers = readers;
            _writers = writers;

            OutputFormats        = _writers.Select(w => w.FormatDescription).ToArray();
            SelectedOutputFormat = OutputFormats.First();

            BrowseInputFileCommand  = new BasicCommand(DoBrowseInput);
            BrowseOutputFileCommand = new BasicCommand(DoBrowseOutput);
            ExitCommand             = new BasicCommand(DoExit);
            _convertCommand         = new AsyncCommand(Convert, CanConvert);
            CancelCommand           = new BasicCommand(DoCancel);
        }
Пример #16
0
        public async Task ScheduleAsync_DeleteSchedulesThatExistButHaveDifferentCronExpressions()
        {
            // Arrange
            var name              = BaseValueGenerator.Word();
            var queueName         = Default.Queue;
            var cron              = Cron.Daily();
            var payload           = Guid.NewGuid().ToByteArray();
            var command           = new BasicCommand();
            var cancellationToken = CancellationToken.None;
            var existingItem      = new ScheduleItem
            {
                Id             = Guid.NewGuid(),
                CronExpression = Cron.Weekly().Expression,
                Name           = name,
                Payload        = Guid.NewGuid().ToByteArray(),
                Queue          = queueName
            };

            _payloadSerializer.SerializeAsync(command, cancellationToken).Returns(Task.FromResult(payload));
            _scheduleProviderFactory.CreateAsync(queueName, cancellationToken).Returns(Task.FromResult(_scheduleProvider));
            _scheduleProvider.LoadByNameAsync(name, cancellationToken).Returns(Task.FromResult(existingItem));

            // Act
            await _sut.ScheduleAsync(name, command, Cron.Daily(), cancellationToken);

            // Assert
            await _scheduleProvider.Received(1).DeleteAsync(existingItem.Id, cancellationToken);

            await _scheduleProvider.Received(1).CreateAsync(Arg.Is <ScheduleItem>(x => x.Queue == queueName && x.CronExpression == cron.Expression), cancellationToken);
        }
Пример #17
0
 public CertificateViewModel(IViewModelDialogs pDialogs, ConfigurationPipeClient pConfigClient,
                             CertificateDetails pCertificate)
 {
     _dialogs      = pDialogs;
     _configClient = pConfigClient;
     _certificate  = pCertificate;
     DeleteCommand = new BasicCommand(OnDelete);
 }
        public MainWindowViewModel()
        {
            var utilizator = AppSettings.LoggedMedic;

            NumeUtilizator       = utilizator.Nume + " " + AppSettings.LoggedMedic.Prenume;
            InstitutieUtilizator = utilizator.Utilizator.InstitutieAsociata1.Nume;
            HandleLogoutCommand  = new BasicCommand(Logout);
        }
 public RoomTemplate()
 {
     // submit command van submitknop
     Submit = new BasicCommand(SubmitRoom);
     // bind het templatecommand van de templateknoppen
     TemplateButton = new ArgumentCommand <int>(SetTemplate);
     MessageQueue   = new SnackbarMessageQueue();
 }
Пример #20
0
 private void InitCommands()
 {
     AddAttendanceCommand = new BasicCommand(AddAttendance);
     AddStudentCommand    = new BasicCommand(AddStudent);
     AddLectureCommand    = new BasicCommand(AddLecture);
     ReloadTablesCommand  = new BasicCommand(ReloadTables);
     SetDefaultsCommand   = new BasicCommand(SetDefaults);
 }
Пример #21
0
 private void OnCommandExecTimerTick(object sender, EventArgs e)
 {
     if (commandQueue.Count > 0)
     {
         BasicCommand cmd = commandQueue.Dequeue();
         ProcessCommand(cmd);
     }
 }
Пример #22
0
 public WorkItemDisplayViewModel(WorkItemPublic workItem, int dayOffset, ITerminalContext context)
 {
     WorkItem              = workItem;
     mDayOffset            = dayOffset;
     mContext              = context;
     ShowEditDialogCommand = new BasicCommand(this.ShowEditDialog);
     UpdateDisplayProperties();
 }
Пример #23
0
        public void SetCommand(EventPage PageData, BasicCommand Command, int Indent = -1)
        {
            this.PageData = PageData;
            this.Command  = Command;
            if (Indent == -1 && Command != null)
            {
                Indent = Command.Indent;
            }
            this.Indent = Indent;
            this.Sprites["bullet"].X = Indent * CommandBox.Indent + 6;
            this.Sprites["bullet"].Y = 9;
            HeaderLabel.SetPosition(19 + Indent * CommandBox.Indent, HeaderLabel.Position.Y);
            if (this.Command == null)
            {
                SetHeight(20);
                return;
            }
            this.CommandType = CommandPlugins.CommandTypes.Find(t => t.Identifier == Command.Identifier.Substring(1)).EmptyClone();
            if (this.Command != null && this.CommandType.IsSubBranch)
            {
                this.Sprites["bullet"].Visible = false;
                WidgetContainer.SetPosition(30 + Indent * CommandBox.Indent, WidgetContainer.Position.Y);
            }
            else
            {
                WidgetContainer.SetPosition(19 + Indent * CommandBox.Indent, WidgetContainer.Position.Y);
            }
            HeaderLabel.SetText(this.CommandType.Name);
            HeaderLabel.SetVisible(this.CommandType.ShowHeader);
            dynamic basewidgets = this.CommandType.CallCreateReadOnly();

            HeaderLabel.SetTextColor(this.CommandType.HeaderColor);
            for (int i = 0; i < basewidgets.Count; i++)
            {
                dynamic widget = basewidgets[i];
                string  type   = widget.GetType().Name;
                Widget  parent = null;
                if (widget.Parent != null)
                {
                    foreach (string parentwidgetid in DynamicReadOnlyWidgets.Keys)
                    {
                        if (parentwidgetid == widget.parent.UniqueID)
                        {
                            parent = DynamicReadOnlyWidgets[parentwidgetid];
                            break;
                        }
                    }
                }
                if (parent == null)
                {
                    parent = WidgetContainer;
                }
                Widget w = ProcessWidgetType(widget, type, parent);
                ProcessWidget(w, widget, false, true);
                DynamicReadOnlyWidgets.Add(widget.UniqueID, w);
            }
            Reload();
        }
        public MainWindowViewModel()
        {
            var utilizator = AppSettings.LoggedDonator;

            NumeUtilizator       = utilizator.Nume + " " + AppSettings.LoggedDonator.Prenume;
            InstitutieUtilizator = utilizator.Utilizator.InstitutieAsociata1.Nume;
            GrupaDeSange         = utilizator.GrupaDeSangeObj.ToString();
            HandleLogoutCommand  = new BasicCommand(Logout);
        }
Пример #25
0
        public void ShouldFailToExecuteOverridingModelWithNewInstance()
        {
            var request   = new Request("Test");
            var commander = new Commander <Request, Model>(request);

            Action action = () => commander.Execute(BasicCommand.Instance(Repo.Instance()), CommandOverridesModel.Instance());

            action.Should().Throw <ApplicationException>().WithMessage("Model cannot be replaced with another instance.");
        }
Пример #26
0
        public Task_11_02ViewModel()
        {
            TextEditor = new TextEditor();

            NewCommand    = new BasicCommand(_CreateNewFile);
            OpenCommand   = new BasicCommand(_OpenFile);
            SaveCommand   = new BasicCommand(_SaveFile);
            SaveAsCommand = new BasicCommand(_SaveFileAs);
        }
 public ManageInstitutiiViewModel()
 {
     Institutii = new ObservableCollection <InstitutieAsociataViewModel>();
     LoadData();
     SelectedInstitutie      = Institutii[0];
     DeleteInstCommand       = new BasicCommand(DeleteInst);
     AdaugaInstitutieCommand = new BasicCommand(AdaugaInstitutie);
     UpdateInstitutieCommand = new BasicCommand(UpdateInstitutie);
 }
Пример #28
0
        public void rollbackRecoveryModel()
        {
            BasicCommand command = getNextCommand();

            if (command != null)
            {
                command.recoveryModel();
            }
        }
Пример #29
0
 public Task_06_03ViewModel()
 {
     CalculateCommand   = new BasicCommand(Calculate);
     ClearOutputCommand = new BasicCommand(obj =>
     {
         Output = string.Empty;
         OnPropertyChanged(nameof(Output));
     });
 }
Пример #30
0
        public void recoveryModel()
        {
            BasicCommand command = getPreviousCommand();

            if (command != null)
            {
                command.recoveryModel();
            }
        }
Пример #31
0
 public void InterpreteSingle(BasicCommand cmd)
 {
     if (cmd.CommandName == CMD_ENABLE_GAMEOBJECT)
         cmdEnableGameObject(cmd.CommandParameter);
     if (cmd.CommandName == CMD_DISABLE_GAMEOBJECT)
         cmdDisableGameObejct(cmd.CommandParameter);
     if (cmd.CommandName == CMD_CAMERA_LOCK)
         cmdCameraLock();
     if (cmd.CommandName == CMD_CAMERA_UNLOCK)
         cmdCameraUnlock();
     if (cmd.CommandName == CMD_MESSAGE_ADD)
         cmdAddMessgae(cmd.CommandParameter);
     if (cmd.CommandName == CMD_MESSAGE_SHOW)
         cmdShowMessage();
 }
Пример #32
0
 public Sequence(BasicCommand b)
     : this()
 {
     commands.Add(b);
 }
        public bool TryParseBasicCommand(string s, List<IRWrapper.IServo> allServos, out BasicCommand bc)
        {
            var chunks = s.Split('|');

            if (chunks.Length < 8)
            {
                Logger.Log("Invalid number of chunks in BasicCommand string: " + s, Logger.Level.Debug);
                bc = null;
                return false;
            }

            bc = new BasicCommand(false);

            if (chunks[0] != "null")
            {
                uint servoUID;
                if (!uint.TryParse(chunks[0], out servoUID))
                {
                    bc = null;
                    return false;
                }
                else
                {
                    bc.servo = allServos.Find(p => p.UID == servoUID);
                    if (bc.servo == null)
                    {
                        bc = null;
                        return false;
                    }
                }

                if (!float.TryParse(chunks[1], out bc.position))
                {
                    bc = null;
                    return false;
                }

                if (!float.TryParse(chunks[2], out bc.speedMultiplier))
                {
                    bc = null;
                    return false;
                }
            }

            if (!bool.TryParse(chunks[3], out bc.wait))
            {
                bc = null;
                return false;
            }

            if (!float.TryParse(chunks[4], out bc.waitTime))
            {
                bc = null;
                return false;
            }

            if (!int.TryParse(chunks[5], out bc.gotoIndex))
            {
                bc = null;
                return false;
            }

            if (!int.TryParse(chunks[6], out bc.gotoCommandCounter))
            {
                bc = null;
                return false;
            }
            else
                bc.gotoCounter = bc.gotoCommandCounter;

            int temp = 0;
            if (!int.TryParse(chunks[7], out temp))
            {
                bc = null;
                return false;
            }
            else
                bc.ag = (KSPActionGroup)temp;

            //Add agX support
            if (chunks.Length > 8)
            {
                temp = -1;
                if (!int.TryParse(chunks[8], out temp))
                {
                    bc = null;
                    return false;
                }
                else
                    bc.agX = temp;
            }

            Logger.Log("Successfully parsed BasicCommand, bc.gotoIndex = " + bc.gotoIndex + ", bc.ag=" + bc.ag);

            return true;
        }