// public EmployeeViewModel(EmployeeView view) // ingen referens? public EmployeeViewModel(EmployeeView view) { this.View = view; Hide = true; RegistratedAlumnus = new ObservableCollection <Alumnus>(UnitOfWork.Alumnuses.GetAll()); AvailableActivities = new ObservableCollection <Activity>(UnitOfWork.Activities.GetAllActivitysWithAlumnus()); SendLists = new ObservableCollection <SendList>(UnitOfWork.SendLists.GettAllSendListWithAlumnuses(OnlineEmployee.ID)); //1 AddActivity = new MainCommand(AddAlumnToActivity); AddSendList = new MainCommand(AddAlumnToSendList); DeleteAlumn = new MainCommand(DeleteAlumnus1); SaveAlumn = new MainCommand(SaveAlumnus); //2 ShowActivity = new MainCommand(ShowHideAlumnAtActivity); SaveActivity = new MainCommand(SaveActivities); DeleteActivity = new MainCommand(DeleteAlumnAtActivity); //3 CreateSendList = new MainCommand(CreateSendLists); DeleteAlumnAtSendList = new MainCommand(DeleteAlumns2); DeleteSendlist = new MainCommand(DeleteSendLists); LogOut = new MainCommand(CloseView); }
//public string PersonCodeBox //{ // get // { // return personCodeBox; // } // set // { // personCodeBox = value; // } //} //public string WelcomeMessage //{ // get // { // IPerson person; // person = Alumnuses.Where(x => x.PersonCode.ToString() == personCodeBox).FirstOrDefault(); // if(person is Alumnus) // { // return person.Fname; // } // person = Alumnuses.Where(x => x.PersonCode.ToString() == personCodeBox).FirstOrDefault(); // if (person is Employee) // { // return person.Fname; // } // else // { // return string.Empty; // } // } //} public LogInViewModel(MainWindow view) { this.view = view; Alumnuses = new ObservableCollection <Alumnus>(UnitOfWork.Alumnuses.GetAll()); Employees = new ObservableCollection <Employee>(UnitOfWork.Employees.GetAll()); LogIn = new MainCommand(Authentication); Registration = new MainCommand(CreateUser); }
public AlumnusViewModel(AlumnusView view) { this.view = view; AvailableActivities = new ObservableCollection <Activity>(UnitOfWork.Activities.GetAll()); BookedActivities = new ObservableCollection <Activity>(UnitOfWork.Activities.GetActivityWithAlumnus(AlumnusOnline.ID)); Book = new MainCommand(BookActivity); CancelBooking = new MainCommand(CanceledAktivity); Change = new MainCommand(ChangeAlumnus); LogOut = new MainCommand(CloseView); }
public ButtonsViewModel() { MainWindowClick = new MainCommand(this); TemperatureWindowClick = new TemperatureCommand(this); PressureWindowClick = new PressureCommand(this); HumidityWindowClick = new HumidityCommand(this); Messenger.Default.Register <MvvmMessage>(this, HandleMessage); DisableAllButtons(); PlotIsVisible = Visibility.Hidden; }
protected override int ExecuteCommand(CommandLineApplication app, IConsole console) { if (BareVersion) { Out.WriteResultOnNewLine(RunningAssembly.Info.AssemblyVersion.ToString()); } else { MainCommand.DrawLogo(Out); } return(0); }
public void Execution_CallingANestedSubCommand_CallExecuteOnNestedSubCommand() { //Arrange var arguments = new[] { "inherited-command" }; var command = new MainCommand(); //Act var sum = command.Execute(arguments); //Assert Assert.Equal(3, sum); }
public void Execution_CallingASubCommandWithDifferentCasing_CallExecuteOnSubCommand() { //Arrange var arguments = new[] { "SUBCOMMAND" }; var command = new MainCommand(); //Act var hashCode = command.Execute(arguments); //Assert Assert.Equal(typeof(SubCommand).GetHashCode(), hashCode); }
public CommandsViewModel(IApplicationCommands applicationCommands) { ApplicationCommands = applicationCommands; Title = GetModuleTitle(Assembly.GetExecutingAssembly()); IncrementCommand = new DelegateCommand(Increment) .ObservesCanExecute(() => IsEnabled); AsyncCommand = new DelegateCommand(async () => await HeavyTask()) .ObservesCanExecute(() => ReadyToRun); MainCommand.ObservesCanExecute(() => IsEnabled); ApplicationCommands.MainCommand.RegisterCommand(MainCommand); }
public ChangeViewModel(ChangeView view) { this.view = view; Firstname = AlumnusOnline.Fname; Lastname = AlumnusOnline.Lname; PersonCode = AlumnusOnline.PersonCode; Email = AlumnusOnline.Email; PhoneNumber = AlumnusOnline.PhoneNumber.ToString(); Qualification = AlumnusOnline.Qualification; ExamDate = AlumnusOnline.ExamDate.ToString(); Change = new MainCommand(ChangeAlumnus); Cancel = new MainCommand(CloseView); }
public void HelpBuilding_BuildingFullHelp_OutputsAllSubCommandsToHelp() { //Arrange var command = new MainCommand(); var builder = new HelpBuilder(command, command.Help); //Act builder.BuildHelp(); //Assert Assert.Contains("inherited-command", command.Help.Usage); Assert.Contains("required", command.Help.Usage); Assert.Contains("subcommand", command.Help.Usage); }
public void Execution_CallingWithVersionOption_CallToVersionProvider() { //Arrange var appInfoMock = new Mock <IAppInfoProvider>(); var arguments = new[] { "-v" }; var command = new MainCommand() { AppInfo = appInfoMock.Object }; //Act command.Execute(arguments); //Assert appInfoMock.Verify(a => a.LongVersion, Times.Once()); }
public void Execution_CallingWithHelpOption_CallToHelpTextProvider() { //Arrange var outputMock = new Mock <IOutputProvider>(); var arguments = new[] { "-h" }; var command = new MainCommand() { Output = outputMock.Object }; //Act command.Execute(arguments); //Assert outputMock.Verify(o => o.ShowInformation(It.IsAny <string>()), Times.Once()); }
public void SendData(int mainId, int subId, BaseCmd cmdObj, List <string> desireReceiver) { if (IsStarted() == false) { return; } MainCommand command = new MainCommand(); command.mainCommandId = mainId; command.subCommandId = subId; command.data = cmdObj.getCommandString(); string message = serializer.Serialize(command); _SessionMgr.SendMessage(message, desireReceiver); }
public void BroadcastMessage(int mainId, int subId, BaseCmd cmdObj) { if (IsStarted() == false) { return; } MainCommand command = new MainCommand(); command.mainCommandId = mainId; command.subCommandId = subId; command.data = cmdObj.getCommandString(); string message = serializer.Serialize(command); _SessionMgr.BroadcastMessage(message); }
public void Parsing_ProvidingArgumentsToCommandWithoutArguments_NoArgumentExistsCalled() { //Arrange var outputMock = new Mock <IOutputProvider>(); var errorMessage = new NoArgumentsExistException().Message; var arguments = new[] { "non-existing-command" }; var command = new MainCommand() { Output = outputMock.Object }; //Act command.Execute(arguments); //Assert outputMock.Verify(o => o.ShowError(It.Is <string>(s => s.Equals(errorMessage))), Times.Once()); }
public PlaylistViewModel(IPlaylist playlist) { Playlist = playlist; GetSongs = new MainCommand( x => true, x => OpenFileDialog()); DeleteSong = new MainCommand( x => CanClearOrDelete(), x => Delete()); Clear = new MainCommand( x => CanClearOrDelete(), x => Playlist.SongsList.ToList().All(x => Playlist.SongsList.Remove(x))); }
void HandleMessage(byte[] bytes, int length) { byte[] temp = new byte[length]; Array.Copy(bytes, 0, temp, 0, length); //接受到的消息总长度 if (length >= 12) { byte[] messageLenBytes = new byte[4]; Array.Copy(bytes, 0, messageLenBytes, 0, 4); int messageLenth = BitConverter.ToInt32(messageLenBytes, 0); byte[] mainComBytes = new byte[4]; Array.Copy(temp, 4, mainComBytes, 0, 4); MainCommand mainCommand = (MainCommand)(BitConverter.ToInt32(mainComBytes, 0)); byte[] subComBytes = new byte[4]; Array.Copy(temp, 8, subComBytes, 0, 4); SubCommand subCommand = (SubCommand)(BitConverter.ToInt32(subComBytes, 0)); byte[] messageBytes = new byte[messageLenth]; Array.Copy(temp, 12, messageBytes, 0, messageLenth); if (mainCommand == MainCommand.Login) { using (MemoryStream stream = new MemoryStream(messageBytes)) { if (subCommand == SubCommand.Login) { } else if (subCommand == SubCommand.Register) { Debug.Log("注册成功:" + BitConverter.ToInt16(messageBytes, 0)); } } } } else if (length < 12) { } }
public SongViewModel(ISong song) { Song = song; Play = new MainCommand( x => CanPlay(x as IPlaylist), x => PlaySong(x as IPlaylist)); Pause = new MainCommand( x => CanPause(), x => PauseSong()); PlayNext = new MainCommand( x => CanPlay(x as IPlaylist), x => UniversalPlay(x as IPlaylist, PlayType.Next)); PlayBack = new MainCommand( x => CanPlay(x as IPlaylist), x => UniversalPlay(x as IPlaylist, PlayType.Back)); }
public static CommandLineBuilder CreateCommandLineBuilder() { var command = new MainCommand { // Add commands here! new ScanCommand(), new CacheCommand(), new AgentsCommand(), new GitCommand(), new ComputeLibYearCommand() }; var builder = new CommandLineBuilder(command) .UseHost(CreateHostBuilder) .AddMiddleware(async(context, next) => { await LogExecution(context, next); }) .UseExceptionHandler() .UseHelp(); return(builder); }
private static async Task HandleCommand(MainCommand command) { // check what kind of command is it and ALWAYS set Tsc.Result // do stuff with the command var commandExecSuccess = true; try { await CheckGroupingAndUpdateMiners(command); } catch (Exception e) { commandExecSuccess = false; Logger.Error(Tag, $"HandleCommand Exception: {e.Message}"); } finally { // always set command source completed here command.Tsc.SetResult(commandExecSuccess); } }
public void SendData <T>(T data, MainCommand mainCommand, SubCommand subCommand) { byte[] bytes = null; using (MemoryStream stream = new MemoryStream()) { Serializer.Serialize <T>(stream, data); byte[] messageBytes = stream.ToArray(); //消息头协议 积累消息长度+主命令+子命名+消息 bytes = new byte[12 + messageBytes.Length]; byte[] messageLenBytes = BitConverter.GetBytes(messageBytes.Length); Array.Copy(messageLenBytes, 0, bytes, 0, 4); Array.Copy(messageBytes, 0, bytes, 12, messageBytes.Length); } byte[] mainBytes = BitConverter.GetBytes((int)mainCommand); Array.Copy(mainBytes, 0, bytes, 4, 4); byte[] subBytes = BitConverter.GetBytes((int)subCommand); Array.Copy(subBytes, 0, bytes, 8, 4); SendData(bytes); }
public LogoutCommand(MainCommand main, IConsole console, Common common) { _main = main; _console = console; _common = common; }
public SetCommand(MainCommand main) { Main = main; }
public NewCommand(MainCommand main) { Main = main; }
public GetOtpCommand(GetCommand parent, IConsole console) { _main = parent.Main; _console = console; }
public ListRecordsCommand(ListCommand parent, IConsole console) { _main = parent.Main; _console = console; }
public ListTemplatesCommand(ListCommand parent, IConsole console) { _main = parent.Main; _console = console; }
public UnlockCommand(MainCommand main, IConsole console) { _main = main; _console = console; }
public NewVaultCommand(NewCommand parent, IConsole console) { _main = parent.Main; _console = console; }
static int Main(string[] args) { var app = new MainCommand(); return(app.Execute(args)); }