public void MyDispose() { foreach (var Comm in MLocalCommands) { Comand.Remove(Comm.Key); } }
static void Main(string[] args) { FileManager fm = FileManager.GetFileManager(); while (true) { Comand comand = fm.GetInputComand(); if (comand != Comand.None) { switch (comand) { case Comand.Save: fm.SaveChanges(); break; case Comand.ChooseSave: fm.ChooseSave(fm.GetLastDirectoryPath()); break; case Comand.Revert: fm.RevertChanges(); break; } Console.WriteLine(comand); Thread.Sleep(1000); } } }
public override async Task Monitorar(Comand comand, IServerStreamWriter <Resposta> responseStream, ServerCallContext context) { Comando comando = new Comando((Comandos)comand.Cmd, comand.Chave, comand.Valor); Requisicao req = new Requisicao(context, comando); string resposta = ""; lock (blockComandos) { filaComandos.Enqueue(req); } bool flag = true; while (flag) { resposta = ""; lock (req.block) { if (req.respostas.Count > 0) { resposta = req.respostas.Dequeue(); } if (!req.HaRespostas && req.respostas.Count <= 0) { flag = false; } } if (resposta != "") { Resposta resp = new Resposta(); resp.Mensagem = resposta; await responseStream.WriteAsync(resp); } } }
public void MyDispose() { foreach (KeyValuePair <Comands, Action <BaseCommand> > mComm in mLocalCommands) { Comand.Remove(mComm.Key); } Draw -= EngineConsole_Draw; }
void Start() { UpComand = new UpComand(); DownComand = new DownComand(); LeftComand = new LeftComand(); rightComand = new RightComand(); Stopcomand = new StopComand(); Play = this.gameObject.GetComponent <PlayerCarController> (); }
// Server side handler of the SayHello RPC public override Task <Resposta> Comando(Comand comand, ServerCallContext context) { Comando comando = new Comando((Comandos)comand.Cmd, comand.Chave, comand.Valor); Requisicao req = new Requisicao(context, comando); lock (blockComandos) { filaComandos.Enqueue(req); } return(Task.FromResult(ProcessaComando(req))); }
public Bouqet ExecuteCommand(Comand command, string param) { Bouqet b = new Bouqet(); switch (command) { case Comand.FindByColor: b = FindByColor(param); return(b); case Comand.SortByParam: SortByName(); break; } return(b); }
private void InitControls() { mLocalCommands.Add(Comands.Left, GeneralMove); mLocalCommands.Add(Comands.TenStepsLeft, GeneralMove); mLocalCommands.Add(Comands.Right, GeneralMove); mLocalCommands.Add(Comands.TenStepsRight, GeneralMove); mLocalCommands.Add(Comands.Up, GeneralMove); mLocalCommands.Add(Comands.TenStepsUp, GeneralMove); mLocalCommands.Add(Comands.Down, GeneralMove); mLocalCommands.Add(Comands.TenStepsDown, GeneralMove); mLocalCommands.Add(Comands.GenerateALotOfRooms, GenerateRooms); mLocalCommands.Add(Comands.GenerateOneRoom, GenerateRooms); mLocalCommands.Add(Comands.GenerateRandomPath, GeneratePath); foreach (KeyValuePair <Comands, Action <BaseCommand> > mComm in mLocalCommands) { Comand.Add(mComm.Key, mComm.Value); } }
private void InitControls() { MLocalCommands.Add(Comands.Left, GeneralMove); MLocalCommands.Add(Comands.TenStepsLeft, GeneralMove); MLocalCommands.Add(Comands.Right, GeneralMove); MLocalCommands.Add(Comands.TenStepsRight, GeneralMove); MLocalCommands.Add(Comands.Up, GeneralMove); MLocalCommands.Add(Comands.TenStepsUp, GeneralMove); MLocalCommands.Add(Comands.Down, GeneralMove); MLocalCommands.Add(Comands.TenStepsDown, GeneralMove); MLocalCommands.Add(Comands.GenerateALotOfRooms, GenerateRooms); MLocalCommands.Add(Comands.GenerateOneRoom, GenerateRooms); MLocalCommands.Add(Comands.GenerateRandomPath, GeneratePath); foreach (var Comm in MLocalCommands) { Comand.Add(Comm.Key, Comm.Value); } }
private void InputHandling() { while (true) { Comand comand = fm.GetInputComand(); if (comand != Comand.None) { switch (comand) { case Comand.Save: fm.SaveChanges(); break; case Comand.ChooseSave: if (IsGameRunning()) { PrintErrorMessage(); break; } fm.ChooseSave(GetFolderPath()); break; case Comand.Revert: if (IsGameRunning()) { PrintErrorMessage(); break; } fm.RevertChanges(); break; } Thread.Sleep(1000); } Thread.Sleep(50); } }
public void Call() { OnStart(this); if (Output.Target == Target.Library) { Comand += " -gc -op"; Comand += " -lib"; Comand += " -H -Hd\"" + Output.Headers + "\""; } Comand += " -of\"" + FileItem.BuildNormalizedPath(Output.Assembly.Location) + Output.Assembly.Name.Replace(".", "") + OutputExtension + "\""; foreach (string import in Input.Import) { string clearImport = SolutionDirectory + import; if (Output.Target == Target.Executable) { Comand += LinkerLibSearchOption + FileItem.BuildNormalizedPath(clearImport, true); } Comand += " -I" + FileItem.BuildNormalizedPath(clearImport); } foreach (FileItem file in Input.Files) { Comand += " \"" + file.Location + file.Name + "\""; } Comand = Comand.Trim(); OnBeforeCompile(this, Comand); Process compiler = new Process { StartInfo = new ProcessStartInfo { FileName = _driver.Location, Arguments = Comand, CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true } }; compiler.Start(); while (!compiler.StandardOutput.EndOfStream) { OnCompile(this, compiler.StandardOutput.ReadToEnd()); } while (!compiler.StandardError.EndOfStream) { OnError(this, compiler.StandardError.ReadToEnd()); } FileItem.MoveMassive(WorkingDirectory, Output.Headers, "*.di"); OnSuccess(this); }
void Start() { UpComand = new UpComand(); Play = this.gameObject.GetComponent <PlayerCarController> (); }
public Operation(Comand cmd) { Cmd = cmd; }
//Realiza un Update sobre la base de datos public void FbUpdate() { _Comand = new FbCommand(this.StrCadena, _Conect); _Conect.Open(); Comand.ExecuteNonQuery(); }
static void Main(string[] args) { if (!File.Exists("portas.txt")) { var stream = File.Create("portas.txt"); stream.Close(); StreamWriter arq = new StreamWriter("portas.txt"); arq.WriteLine("1700"); arq.WriteLine("127.0.0.1"); arq.Close(); } StreamReader file = new StreamReader("portas.txt"); porta = int.Parse(file.ReadLine()); endereco = file.ReadLine(); Channel channel = new Channel(endereco + ":" + porta, ChannelCredentials.Insecure); client = new RPC.RPCClient(channel); String data; int comand; int chave; Task task = null; while (true) { Console.WriteLine("Qual comando(ADD-1/READ-2/UPDATE-3/DELETE-4/LISTAR-5/DESLIGAR-6)/MONITORAR-7"); if (!int.TryParse(Console.ReadLine(), out comand) || comand <= 0 || comand > 7) { Console.WriteLine("Comando Inválido!"); continue; } switch (comand) { case (int)Comandos.ADD: Console.WriteLine("Insira chave"); if (!int.TryParse(Console.ReadLine(), out chave)) { Console.WriteLine("Chave inválida"); continue; } Console.WriteLine("Insira dado"); data = Console.ReadLine(); cmd = new Comand(); cmd.Chave = chave; cmd.Valor = data; cmd.Cmd = comand; task = new Task(ThreadGRPC); break; case (int)Comandos.READ: Console.WriteLine("Insira chave"); if (!int.TryParse(Console.ReadLine(), out chave)) { Console.WriteLine("Chave inválida"); continue; } cmd = new Comand(); cmd.Chave = chave; cmd.Cmd = comand; task = new Task(ThreadGRPC); break; case (int)Comandos.UPDATE: Console.WriteLine("Insira chave"); if (!int.TryParse(Console.ReadLine(), out chave)) { Console.WriteLine("Chave inválida"); continue; } Console.WriteLine("Insira dado"); data = Console.ReadLine(); cmd = new Comand(); cmd.Chave = chave; cmd.Valor = data; cmd.Cmd = comand; task = new Task(ThreadGRPC); break; case (int)Comandos.DELETE: Console.WriteLine("Insira chave"); if (!int.TryParse(Console.ReadLine(), out chave)) { Console.WriteLine("Chave inválida"); continue; } cmd = new Comand(); cmd.Chave = chave; cmd.Cmd = comand; task = new Task(ThreadGRPC); break; case (int)Comandos.DESLIGAR: break; case (int)Comandos.LISTAR: cmd = new Comand(); cmd.Cmd = comand; task = new Task(ThreadListar); break; case (int)Comandos.MONITORAR: Console.WriteLine("Insira chave"); if (!int.TryParse(Console.ReadLine(), out chave)) { Console.WriteLine("Chave inválida"); continue; } cmd = new Comand(); cmd.Cmd = comand; cmd.Chave = chave; task = new Task(ThreadMonitorar); break; } if (cmd != null && task != null) { task.Start(); } } }
public static void X() { string S = Console.ReadLine(); int CountCommantFirstDivision = int.Parse(S.Split(' ')[0]); int CountCommantSecondDivision = int.Parse(S.Split(' ')[1]); List <Comand> CMFirst = new List <Comand>(); List <Comand> CMSecond = new List <Comand>(); //заполняем масивы команд первого и второго дивизиона for (int i = 0; i < CountCommantFirstDivision; i++) { string s = Console.ReadLine(); Comand C = new Comand(); C.Id = int.Parse(s.Split(' ')[0]); C.CompletedAssignments = int.Parse(s.Split(' ')[1]); C.PenaltyTime = int.Parse(s.Split(' ')[2]); if (C.CompletedAssignments > 0) { //добавляем только решивших хотябы 1 CMFirst.Add(C); } } //прошедшие команды List <int> IDComandWIN = new List <int>(); for (int i = 0; i < CountCommantSecondDivision; i++) { string s = Console.ReadLine(); Comand C = new Comand(); C.Id = int.Parse(s.Split(' ')[0]); C.CompletedAssignments = int.Parse(s.Split(' ')[1]); C.PenaltyTime = int.Parse(s.Split(' ')[2]); if (C.CompletedAssignments > 0) { //добавляем только решивших хотябы 1 IDComandWIN.Add(C.Id); } } //сортируем по количеству балов и штрафному времени CMFirst = CMFirst.OrderByDescending(asa => asa.CompletedAssignments).ThenBy(assa => assa.PenaltyTime).ToList(); int MaxComplete = 0; if (CMFirst.Count > 0) { MaxComplete = CMFirst[0].CompletedAssignments; } //добавляем всех кто выполнил столькоже сколько победитель foreach (var item in CMFirst) { if (item.CompletedAssignments == MaxComplete) { IDComandWIN.Add(item.Id); } } //середина списка int CentepPlace = CMFirst.Count() / 2 - 1; int CenterCountComplete = 9999; if (CentepPlace > 0) { CenterCountComplete = CMFirst[CentepPlace].CompletedAssignments; } //добавляем всех кто до середины и набрал больше балов чем центральный for (int i = 0; i < CentepPlace; i++) { if (CMFirst[i].CompletedAssignments > CenterCountComplete) { IDComandWIN.Add(CMFirst[i].Id); } } IDComandWIN = IDComandWIN.Distinct().ToList(); IDComandWIN.Sort(); Console.WriteLine(IDComandWIN.Count); foreach (var id in IDComandWIN) { Console.Write(id + " "); } Console.WriteLine(); }