public void Do(Act action, Until until = null, Act then = null) { var di = new DoInfo(); di.Do = action; di.Until = until; di.Then = then; Dos.Add(di); }
public void Do(Act action, Until until = null, Act then = null) { DoInfo di = new DoInfo { Do = action, Until = until, Then = then }; Dos.Add(di); }
public static async Task MainAsync(string[] args) { try{ int nb; C.WL("Choose program:\n\n 1: SocketChat \n\n 2: HttpChat \n"); C.WL(" 3: TypingGame \n\n 4: Matrix \n\n 5: Randomizer"); restart: if (args.Length > 0) { U.ParseInt(args[0], out nb); Console.Clear(); } else if (!U.ParseInt(C.Read(), out nb)) { goto restart; } switch (nb) { case 1: SocketChat.Begin(cts.Token); break; case 2: LauncHttpChatServer(); break; case 3: TypingGame.Begin().Wait(); break; case 4: Matrix.Start(cts.Token); break; case 5: Randomizer.Randomize(); break; case 6: Dos.TcpFloodAttack(); break; case 7: Dos.UdpFloodAttack(); break; default: goto restart; } } catch (Exception) { EndTasks(); } finally{ await MainAsync(args); } }
public void Add(object item) { if (IgnoreDecl) { return; } else if (item is P_Root.MachineSends) { MachineSends.Add(item as P_Root.MachineSends); } else if (item is P_Root.MachineReceives) { MachineReceives.Add(item as P_Root.MachineReceives); } else if (item is P_Root.MachineProtoDecl) { MachineProtoDecls.Add(item as P_Root.MachineProtoDecl); } else if (item is P_Root.FunProtoDecl) { FunProtoDecls.Add(item as P_Root.FunProtoDecl); } else if (item is P_Root.MachineExports) { MachineExports.Add(item as P_Root.MachineExports); } else if (item is P_Root.EventSetContains) { EventSetContains.Add(item as P_Root.EventSetContains); } else if (item is P_Root.EventSetDecl) { EventSetDecl.Add(item as P_Root.EventSetDecl); } else if (item is P_Root.InterfaceTypeDef) { InterfaceTypeDef.Add(item as P_Root.InterfaceTypeDef); } else if (item is P_Root.ObservesDecl) { Observes.Add(item as P_Root.ObservesDecl); } else if (item is P_Root.Annotation) { Annotations.Add(item as P_Root.Annotation); } else if (item is P_Root.DoDecl) { Dos.Add(item as P_Root.DoDecl); } else if (item is P_Root.AnonFunDecl) { AnonFunctions.Add(item as P_Root.AnonFunDecl); } else if (item is P_Root.FunDecl) { Functions.Add(item as P_Root.FunDecl); } else if (item is P_Root.TransDecl) { Transitions.Add(item as P_Root.TransDecl); } else if (item is P_Root.VarDecl) { Variables.Add(item as P_Root.VarDecl); } else if (item is P_Root.StateDecl) { States.Add(item as P_Root.StateDecl); } else if (item is P_Root.MachineDecl) { Machines.Add(item as P_Root.MachineDecl); } else if (item is P_Root.EventDecl) { Events.Add(item as P_Root.EventDecl); } else if (item is P_Root.ModelType) { ModelTypes.Add(item as P_Root.ModelType); } else if (item is P_Root.EnumTypeDef) { EnumTypeDefs.Add(item as P_Root.EnumTypeDef); } else if (item is P_Root.TypeDef) { TypeDefs.Add(item as P_Root.TypeDef); } else if (item is P_Root.DependsOn) { DependsOn.Add(item as P_Root.DependsOn); } else if (item is P_Root.FunProtoCreatesDecl) { FunProtoCreates.Add(item as P_Root.FunProtoCreatesDecl); } else { throw new Exception("Cannot add into the Program : " + item.ToString()); } }
public void InternalUpdate() { upmut.WaitOne(); var iil = new List <IfInfo>(); foreach (var ci in Ifs) { if (ci.If()) { ci.Action(); } else { if (ci.Else != null) { ci.Else(); } } if (ci.Until != null) { if (ci.Until()) { iil.Add(ci); } } } foreach (var ci in iil) { Ifs.Remove(ci); } var rd = new List <DoInfo>(); var dt = new List <DoInfo>(); foreach (var Do in Dos) { Do.Do(); if (Do.Until != null) { if (Do.Until()) { if (Do.Then != null) { dt.Add(Do); } rd.Add(Do); } } } foreach (var dd in dt) { dd.Then(); } foreach (var Do in rd) { Dos.Remove(Do); } var rw = new List <WhenInfo>(); foreach (var w in Whens) { if (w.When()) { if (w.Unless != null) { if (w.Unless()) { //rw.Add(w); } else { w.Action(); rw.Add(w); } } else { w.Action(); rw.Add(w); } } } foreach (var w in rw) { Whens.Remove(w); } if (Flows.Count > 0) { var ff = Flows[0]; if (ff.Begun == false) { if (ff.Init != null) { ff.Init(); } ff.Begun = true; } if (ff.Logic()) { if (ff.EndLogic != null) { ff.EndLogic(); } Flows.Remove(ff); } } List <ActInfo> rem = new List <ActInfo>(); int ms = Environment.TickCount; foreach (var a in Acts) { if (a.NoTime) { a.Action(); if (a.Until()) { rem.Add(a); continue; } } if (a.Until != null) { if (ms > (a.When)) { a.Action(); if (a.Until()) { rem.Add(a); continue; } } } if (a.Running) { if (ms > (a.When + a.For)) { Console.WriteLine("Done"); rem.Add(a); continue; } } else { if (ms > a.When) { a.Action(); if (a.Once) { rem.Add(a); } else { a.Running = true; } } } } foreach (var a in rem) { Acts.Remove(a); } upmut.ReleaseMutex(); }
public void Add(object item) { if (item is P_Root.AnyTypeDecl) { AnyTypeDecl.Add(item as P_Root.AnyTypeDecl); } else if (item is P_Root.MachineSends) { MachineSends.Add(item as P_Root.MachineSends); } else if (item is P_Root.MachineReceives) { MachineReceives.Add(item as P_Root.MachineReceives); } else if (item is P_Root.EventSetContains) { EventSetContains.Add(item as P_Root.EventSetContains); } else if (item is P_Root.EventSetDecl) { EventSetDecl.Add(item as P_Root.EventSetDecl); } else if (item is P_Root.InterfaceDef) { InterfaceDef.Add(item as P_Root.InterfaceDef); } else if (item is P_Root.ObservesDecl) { Observes.Add(item as P_Root.ObservesDecl); } else if (item is P_Root.Annotation) { Annotations.Add(item as P_Root.Annotation); } else if (item is P_Root.DoDecl) { Dos.Add(item as P_Root.DoDecl); } else if (item is P_Root.AnonFunDecl) { AnonFunctions.Add(item as P_Root.AnonFunDecl); } else if (item is P_Root.FunDecl) { Functions.Add(item as P_Root.FunDecl); } else if (item is P_Root.TransDecl) { Transitions.Add(item as P_Root.TransDecl); } else if (item is P_Root.VarDecl) { Variables.Add(item as P_Root.VarDecl); } else if (item is P_Root.StateDecl) { States.Add(item as P_Root.StateDecl); } else if (item is P_Root.MachineDecl) { Machines.Add(item as P_Root.MachineDecl); } else if (item is P_Root.MachineCard) { MachineCards.Add(item as P_Root.MachineCard); } else if (item is P_Root.MachineKind) { MachineKinds.Add(item as P_Root.MachineKind); } else if (item is P_Root.MachineStart) { MachineStarts.Add(item as P_Root.MachineStart); } else if (item is P_Root.EventDecl) { Events.Add(item as P_Root.EventDecl); } else if (item is P_Root.EnumTypeDef) { EnumTypeDefs.Add(item as P_Root.EnumTypeDef); } else if (item is P_Root.TypeDef) { TypeDefs.Add(item as P_Root.TypeDef); } else if (item is P_Root.DependsOn) { DependsOn.Add(item as P_Root.DependsOn); } else { throw new Exception("Cannot add into the Program : " + item); } }