Esempio n. 1
0
        private static void Main(string[] args)
        {
#if DEBUG
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["debugBreak"]))
            {
                Debugger.Launch();
            }
#endif
            XmlConfigurator.Configure();

            var program = new Program();
            if (Environment.UserInteractive || args.Contains("--console") || args.Contains("-c"))
            {
                program.OnStart(args);

                Console.WriteLine("\r\nPress any key to stop...\r\n");
                Console.ReadKey();

                program.OnStop();
            }
            else
            {
                Run(program);
            }
        }
        public EtwPerformanceMetricLogger(XunitPerformanceProject project, Program program)
        {
            _etlPath = Path.Combine(project.OutputDir, project.OutputBaseFileName + ".etl");
            _program = program;
            _project = project;

            var diagnosticMessageSink = new ConsoleReporter();

            foreach (var assembly in project.Assemblies)
            {
                program.PrintIfVerbose($"Discovering tests for {assembly.AssemblyFilename}.");

                // Note: We do not use shadowCopy because that creates a new AppDomain which can cause
                // assembly load failures with delay-signed or "fake signed" assemblies.
                using (var controller = new XunitFrontController(
                    assemblyFileName: assembly.AssemblyFilename,
                    shadowCopy: false,
                    appDomainSupport: AppDomainSupport.Denied,
                    diagnosticMessageSink: new ConsoleDiagnosticsMessageVisitor())
                    )
                using (var discoveryVisitor = new PerformanceTestDiscoveryVisitor(assembly, project.Filters, diagnosticMessageSink))
                {
                    controller.Find(includeSourceInformation: false, messageSink: discoveryVisitor, discoveryOptions: TestFrameworkOptions.ForDiscovery());
                    discoveryVisitor.Finished.WaitOne();
                    _tests.AddRange(discoveryVisitor.Tests);
                }
            }

            program.PrintIfVerbose($"Discovered a total of {_tests.Count} tests.");
        }
Esempio n. 3
0
        private static void Main(string[] argv)
        {
            Console.WriteLine(argv);
            Console.WriteLine("Hello from Test World!");
            try
            {
                RunNeoTests();
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                RunScenarioTests();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            try
            {
                RunAggregatorTests();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Program program = new Program();
            program.Main();

            Console.WriteLine("So Long from Test World");
        }
Esempio n. 4
0
 static void Main(string[] args)
 {
     Program app = new Program();
     app.dowork();
     Console.Out.WriteLine("Press Enter to Finish");
     Console.ReadLine();
 }
Esempio n. 5
0
 public bool DeleteProgram(Program program)
 {
     if (program == null) return false;
     _unitOfWork.ProgramRepository.Delete(program);
     _unitOfWork.Save();
     return true;
 }
Esempio n. 6
0
 static void Main(string[] args)
 {
     var program = new Program();
     program.Test1();
     Console.WriteLine(".");
     Console.ReadKey();
 }
Esempio n. 7
0
 public DisassemblyTextModel(Program program)
 {
     if (program == null)
         throw new ArgumentNullException("program");
     this.program = program;
     this.position = program.Image.BaseAddress;
 }
Esempio n. 8
0
 public override void Render(ImageMapSegment segment, Program program, Formatter formatter)
 {
     var entries = shdr.sh_size / shdr.sh_entsize;
     var symtab = (int)shdr.sh_link;
     var rdr = loader.CreateReader(shdr.sh_offset);
     for (int i = 0; i < entries; ++i)
     {
         uint iName;
         if (!rdr.TryReadUInt32(out iName))
             return;
         uint value;
         if (!rdr.TryReadUInt32(out value))
             return;
         uint size;
         if (!rdr.TryReadUInt32(out size))
             return;
         byte info;
         if (!rdr.TryReadByte(out info))
             return;
         byte other;
         if (!rdr.TryReadByte(out other))
             return;
         ushort shIndex;
         if (!rdr.TryReadUInt16(out shIndex))
             return;
         string symStr = loader.GetStrPtr(symtab, iName);
         string segName = loader.GetSectionName(shIndex);
         formatter.Write("{0,-40} {1:X8} {2:X8} {3:X2} {4}", symStr, value, size, info & 0xFF, segName);
         formatter.WriteLine();
     }
 }
Esempio n. 9
0
 private static void InstanceDelegateDemo()
 {
     Console.WriteLine("----- Instance Delegate Demo -----");
     Program p = new Program();
     Counter(1, 3, new Feedback(p.FeedbackToFile));
     Console.WriteLine();
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Program p = new Program();
            p.Get();

            Console.ReadLine();
        }
Esempio n. 11
0
        static void Main()
        {
            try
            {
                var program = new Program();

                program.WaitToSendAMessage();

                program.SendAMessage();
            }
            catch (Exception exception)
            {
                var assemblyName = typeof(Program).AssemblyQualifiedName;

                if (!EventLog.SourceExists(assemblyName))
                    EventLog.CreateEventSource(assemblyName, "Application");

                var log = new EventLog { Source = assemblyName };
                log.WriteEntry(string.Format("{0}", exception), EventLogEntryType.Error);
            }
            finally
            {
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }
Esempio n. 12
0
        static void Main()
        {
            Program p = new Program();
            Calculator c = new Calculator();

            // Get first numeric value.
            c.FirstNumber = p.GetNumericValue();

            // Get second numeric value.
            c.SecondNumber = p.GetNumericValue();

            // TODO: Create an instance of the ThreadStart delegate passing
            //      in the Add method of the Calculator class.
            ThreadStart threadStart = new ThreadStart(c.Add);

            // TODO: Declare and create an instance of the secondary thread
            //      passing in the delegate instance.
            Thread thread = new Thread(threadStart);

            //TODO:  Start the secondary thread.
            thread.Start();

            System.Threading.Thread.Sleep(2500);

            Console.WriteLine("\nTotal values: {0}",
                c.TotalValue);

            Console.Write("\nPress any key to end.");
            Console.ReadLine();
        }
Esempio n. 13
0
		///<summary></summary>
		public static void SendData(Program ProgramCur,Patient pat) {
			_path=Programs.GetProgramPath(Programs.GetCur(ProgramName.DemandForce));
			if(!File.Exists(_path)) {
				MessageBox.Show(_path+" could not be found.");
				return;
			}
			if(MessageBox.Show(Lan.g("DemandForce","This may take 20 minutes or longer")+".  "+Lan.g("DemandForce","Continue")+"?","",MessageBoxButtons.OKCancel)!=DialogResult.OK) {
				return;
			}
			_formProg=new FormProgress();
			_formProg.MaxVal=100;
			_formProg.NumberMultiplication=1;
			_formProg.DisplayText="";
			_formProg.NumberFormat="F";//Show whole percentages, not fractional percentages.
			Thread workerThread=new Thread(new ThreadStart(InstanceBridgeExport));
			workerThread.Start();
			if(_formProg.ShowDialog()==DialogResult.Cancel) {
				workerThread.Abort();
				MessageBox.Show(Lan.g("DemandForce","Export cancelled")+". "+Lan.g("DemandForce","Partially created file has been deleted")+".");
				CheckCreatedFile(CodeBase.ODFileUtils.CombinePaths(Path.GetDirectoryName(_path),"extract.xml"));
				_formProg.Dispose();
				return;
			}
			MessageBox.Show(Lan.g("DemandForce","Export complete")+". "+Lan.g("DemandForce","Press OK to launch DemandForce")+".");
			try {
				Process.Start(_path);//We might have to add extract.xml to launch command in the future.
			}
			catch {
				MessageBox.Show(_path+" is not available.");
			}
			_formProg.Dispose();
		}
Esempio n. 14
0
        /// <summary>
        /// Start the console server.
        /// </summary>
        /// <param name="args">These are optional arguments.Pass the local ip address of the server as the first argument and the local port as the second argument.</param>
        public static void Main(string[] args)
        {
            var progDomain = new Program {_clients = new List<ClientManager>()};

            if (args.Length == 0)
            {
                progDomain._serverPort = 8000;
                progDomain._serverIp = IPAddress.Any;
            }
            if (args.Length == 1)
            {
                progDomain._serverIp = IPAddress.Parse(args[0]);
                progDomain._serverPort = 8000;
            }
            if (args.Length == 2)
            {
                progDomain._serverIp = IPAddress.Parse(args[0]);
                progDomain._serverPort = int.Parse(args[1]);
            }

            progDomain._bwListener = new BackgroundWorker {WorkerSupportsCancellation = true};
            progDomain._bwListener.DoWork += progDomain.StartToListen;
            progDomain._bwListener.RunWorkerAsync();

            Console.WriteLine("*** Listening on port {0}{1}{2} started.Press ENTER to shutdown server. ***\n", progDomain._serverIp, ":", progDomain._serverPort);

            Console.ReadLine();

            progDomain.DisconnectServer();
        }
Esempio n. 15
0
        public MainState(Program handle)
            : base(handle,TypeState.Normal)
        {
            _arrayState = new State[9];
            string disconnect = "(disconnect)";
            _menu = new Menu(MainHandle.Display_N18);
            _menu.Title = "SDK Gadgeteer";
            _menu.Lines[0] = "On/off Button led";
            _menu.Lines[1] = "Demo Joystick";
            _menu.Lines[2] = "Demo Timer";
            _menu.Lines[3] = "Demo SDCard";
            _menu.Lines[4] = "Demo Tunes";
            _menu.Lines[5] = "Demo Led Strip";
            _menu.Lines[6] = "Demo Screen";
            _menu.Lines[7] = "Item7";
            _menu.Lines[8] = "Infos,versions,...";

            if (MainHandle.Tunes == null)
                _menu.Lines[4] += disconnect;

            if (MainHandle.LED_Strip == null)
                _menu.Lines[5] += disconnect;

            _menu.Draw();
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            var program = new Program();
            Dictionary<string, bool[]> dados = new Dictionary<string, bool[]>
            {
                {"peixe", new[]{true,false,false,false}},
                {"cachorro", new[]{false,false,true,false}},
                {"cobra", new[]{false,false,false,true}},
                {"tucano", new[]{false,true,false,false}},
                {"batima", new[]{false,true,true,false}},
            };

            var perguntas = new[]
            {
                "Ele nada?",
                "Ele voa?",
                "É um mamífero?",
                "É um reptil?",
            };

            Console.WriteLine("Pense em um animal e tecle alguma coisa...");
            Console.ReadKey();

            bool[] respostas = program.ColetaRespostas(perguntas);

            var animal = program.DescobrirAnimal(dados, respostas);

            Console.WriteLine(animal);

            Console.ReadKey();
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("OMGHAI!");

            var app = new Program()
                          {
                              Items = new List<Item>
                                          {
                                              new Item {Name = "+5 Dexterity Vest", SellIn = 10, Quality = 20},
                                              new Item {Name = "Aged Brie", SellIn = 2, Quality = 0},
                                              new Item {Name = "Elixir of the Mongoose", SellIn = 5, Quality = 7},
                                              new Item {Name = "Sulfuras, Hand of Ragnaros", SellIn = 0, Quality = 80},
                                              new Item
                                                  {
                                                      Name = "Backstage passes to a TAFKAL80ETC concert",
                                                      SellIn = 15,
                                                      Quality = 20
                                                  },
                                              new Item {Name = "Conjured Mana Cake", SellIn = 3, Quality = 6}
                                          }

                          };

            app.UpdateQuality();

            System.Console.ReadKey();
        }
        public void init(int programID, AxMapControl mc, AxToolbarControl tc, MainWindow mw)
        {
            inited = true;

            program = new Program();
            program.id = programID;
            program.select();

            mapControl = mc;
            toolbarControl = tc;
            mainWindow = mw;
            mainRoadList = program.getAllRelatedMainRoad();
            if (mainRoadList == null)
                mainRoadList = new ObservableCollection<MainRoad>();

            foreach (MainRoad mainRoad in mainRoadList)
            {
                GisUtil.DrawPolylineElement(mainRoad.lineElement, mapControl);   
            }

            valid = isValid();
            dirty = false;

            mapControlMouseDown = null;
            MainRoadListBox.ItemsSource = mainRoadList;
        }
Esempio n. 19
0
        protected override void RunTest(Program program, string outputFile)
        {
            var eventListener = new FakeDecompilerEventListener();
            using (FileUnitTester fut = new FileUnitTester(outputFile))
            {
                fut.TextWriter.WriteLine("// Before ///////");
                DumpProgram(program, fut.TextWriter);

                SetupPreStages(program);
                aen.Transform(program);
                eqb.Build(program);
                var coll = new TypeCollector(program.TypeFactory, program.TypeStore, program,eventListener);
                coll.CollectTypes();
                program.TypeStore.BuildEquivalenceClassDataTypes(program.TypeFactory);
                tvr.ReplaceTypeVariables();
                trans.Transform();
                ctn.RenameAllTypes(program.TypeStore);
                ter = new TypedExpressionRewriter(program, eventListener);
                try
                {
                    ter.RewriteProgram(program);
                }
                catch (Exception ex)
                {
                    fut.TextWriter.WriteLine("** Exception **");
                    fut.TextWriter.WriteLine(ex);
                }
                finally
                {
                    fut.TextWriter.WriteLine("// After ///////");
                    DumpProgAndStore(program, fut);
                }
            }
        }
Esempio n. 20
0
        static void Main()
        {
            var generator = new Program();

            generator.RebuildGitParser();
            generator.RebuildGitNumstatParser();
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            var program = new Program();
            Mapper.CreateMap<Customer, CustomerViewItem>();

            Stopwatch watch = new Stopwatch();

            for (int x = 1; x <= 100000; x *= 10)
            {
                program.PopulateCustomers(x);

                watch.Start();
                program.RunMapper(x);
                watch.Stop();
                Console.WriteLine(string.Format("AutoMapper with {0}: {1}", x, watch.ElapsedMilliseconds));

                watch.Reset();

                watch.Start();
                program.RunManual(x);
                watch.Stop();
                Console.WriteLine(string.Format("Manual Map with {0}: {1}", x, watch.ElapsedMilliseconds));
            }

            Console.ReadLine();
        }
        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    FragmentProgramFileName, /* Name of file containing program */
                    fragmentProfile, /* Profile: OpenGL ARB vertex program */
                    FragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();
        }
Esempio n. 23
0
 static void Main(string[] args)
 {
     var p = new Program();
     p.UseIdentityMonad();
     p.UseMaybeMonad();
     Console.ReadLine();
 }
Esempio n. 24
0
        public PyBuildValueFormatParser(
            Program program,
            Address addrInstr,
            string format,
            IServiceProvider services)
        {
            this.ArgumentTypes = new List<DataType>();
            this.format = format;
            var platform = program.Platform;
            this.pointerSize = platform.PointerType.Size;

            var wordSize = platform.Architecture.WordWidth.Size;
            var longSize = platform.GetByteSizeFromCBasicType(
                CBasicType.Long);
            var longLongSize = platform.GetByteSizeFromCBasicType(
                CBasicType.LongLong);
            var doubleSize = platform.GetByteSizeFromCBasicType(
                CBasicType.Double);

            dtInt = Integer(wordSize);
            dtUInt = UInteger(wordSize);
            dtLong = Integer(longSize);
            dtULong = UInteger(longSize);
            dtLongLong = Integer(longLongSize);
            dtULongLong = UInteger(longLongSize);
            dtDouble = Real(doubleSize);
            ptrChar = Ptr(PrimitiveType.Char);
            ptrVoid = Ptr(VoidType.Instance);

            dtPySize = UInteger(pointerSize);
            ptrPyObject = Ptr(Ref("PyObject"));
            ptrPyUnicode = Ptr(Ref("Py_UNICODE"));
            ptrPyComplex = Ptr(Ref("Py_complex"));
            ptrPyConverter = Ptr(new CodeType());
        }
Esempio n. 25
0
 private static void Main(string[] args)
 {
     Program p = new Program();
     string userSelectedOption = "";
     do
     {
         userSelectedOption = p.GetUserInput();
         switch (userSelectedOption)
         {
             case "1":
                 p.DisplayOrders();
                 break;
             case "2":
                 p.AddAnOrder();
                 break;
             case "3":
                 p.EditAnOrder();
                 break;
             case "4":
                 p.RemoveAnOrder();
                 break;
             case "5":
                 break;
             default:
                 Console.Clear();
                 Console.WriteLine("Thats not a valid choice. Please select again");
                 Console.WriteLine("");
                 break;
         }
     } while (userSelectedOption != "5");
 }
Esempio n. 26
0
		public void Visit(Program expression)
		{
			foreach (var statement in expression.Statements)
			{
				statement.Accept(this);
			}
		}
Esempio n. 27
0
        public static List<Error> Translate(Source source)
        {
            var err = new List<Error>();
            var prg = new Program();
            try
            {
                var input = new ANTLRStringStream(source.GetSourceData());
                var lexer = new PascalLexer(input);
                var tokens = new CommonTokenStream(lexer);
                var parser = new PascalParser(tokens);
                prg = parser.program();
                prg.SetSourceIdentifier(source.GetSourceIdentifier());
            }
            catch (RecognitionException e)
            {
                err.Add(new Error(FormatRecognitionException(e, source.GetSourceIdentifier())));
            }
            if (err.Count != 0)
                return err;

            var val = new Validator();
            err = val.Validate(prg);
            Root = prg;
            return err;
        }
Esempio n. 28
0
        /// <summary>
        /// Main method for the sample.
        /// </summary>
        /// <param name="args">command line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                using (var client = new DocumentClient(new Uri(EndpointUrl), AuthorizationKey, ConnectionPolicy))
                {
                    var program = new Program(client);
                    program.RunAsync().Wait();
                    Console.WriteLine("Samples completed successfully.");
                }
            }
#if !DEBUG
            catch (Exception e)
            {
                // If the Exception is a DocumentClientException, the "StatusCode" value might help identity 
                // the source of the problem. 
                Console.WriteLine("Samples failed with exception:{0}", e);
            }
#endif
            finally
            {
                Console.WriteLine("End of samples, press any key to exit.");
                Console.ReadKey();
            }
        }
Esempio n. 29
0
 ///<summary>Launches the program using a combination of command line characters and the patient.Cur data.</summary>
 public static void SendData(Program ProgramCur,Patient pat)
 {
     //Example CerPI.exe -<patNum>;<fname>;<lname>;<birthday DD.MM.YYYY>; (Date format specified in the windows Regional Settings)
     if(pat==null) {
         try {
             Process.Start(ProgramCur.Path);//should start Cerec without bringing up a pt.
         }
         catch {
             MessageBox.Show(ProgramCur.Path+" is not available.");
         }
         return;
     }
     string info= " -" ;
     if(ProgramProperties.GetPropVal(ProgramCur.ProgramNum,"Enter 0 to use PatientNum, or 1 to use ChartNum")=="0") {
         info+=pat.PatNum.ToString()+";";
     }
     else {
         info+=pat.ChartNumber.ToString()+";";
     }
     info+=pat.FName+";"+pat.LName+";"+pat.Birthdate.ToShortDateString()+";";
     try {
         Process.Start(ProgramCur.Path,info);
     }
     catch {
         MessageBox.Show(ProgramCur.Path+" is not available, or there is an error in the command line options.");
     }
 }
Esempio n. 30
0
        static void Main(string[] args)
        {
            //// 0 1 2
            //TreeNode root = new TreeNode(0);
            //TreeNode left = new TreeNode(1);
            //TreeNode right = new TreeNode(2);

            //[5,3,6,1,4,null,null,null,2]
            //node with value 4
            //node with value 2
            TreeNode root = new TreeNode(5);
            TreeNode n1 = new TreeNode(3);
            TreeNode n2 = new TreeNode(6);
            root.left = n1;
            root.right = n2;
            TreeNode n3 = new TreeNode(1);
            TreeNode n4 = new TreeNode(4);
            TreeNode n7 = new TreeNode(2);
            n1.left = n3;
            n1.right = n4;
            n4.right = n7;

            //root.left = left;
            //left.right = right;

            Program p = new Program();

            Console.WriteLine(p.LowestCommonAncestor(root, n4, n7).val);
            Console.ReadKey();
        }
 public CheckoutOrderTests()
 {
     _checkoutOrderUnderTest = new Program();
 }
Esempio n. 32
0
        // Split on the postconditions of procedure "proc"
        // 1. only retain its postconditions; make everything else as assumes
        // 2. drop the implementation of the procedure
        // 3. convert calls to itself to calls to a fake procedure with assumed postconditions
        static Program SplitOnProcedure(Program program, string proc)
        {
            var dup = new FixedDuplicator();

            program = dup.VisitProgram(program);
            program = BoogieUtil.ReResolveInMem(program, true);

            var            toremove = new HashSet <Implementation>();
            Implementation procimpl = null;

            foreach (var impl in program.TopLevelDeclarations.OfType <Implementation>())
            {
                if (impl.Name == proc)
                {
                    procimpl = impl;
                    continue;
                }

                if (impl.Proc.Ensures.All(ens => ens.Free))
                {
                    continue;
                }

                var newens = new List <Ensures>();
                impl.Proc.Ensures.Iter(ens => newens.Add(new Ensures(ens.tok, true, ens.Condition, ens.Comment)));
                impl.Proc.Ensures = newens;
                toremove.Add(impl);
            }

            program.RemoveTopLevelDeclarations(decl => decl is Implementation && toremove.Contains(decl));

            if (procimpl != null)
            {
                // create copy
                var proccopy = dup.VisitProcedure(procimpl.Proc);
                proccopy.Name += "_dup";

                // make assumes
                var newens = new List <Ensures>();
                proccopy.Ensures.Iter(ens => newens.Add(new Ensures(ens.tok, true, ens.Condition, ens.Comment)));
                proccopy.Ensures = newens;

                foreach (var impl in program.TopLevelDeclarations.OfType <Implementation>())
                {
                    foreach (var blk in impl.Blocks)
                    {
                        for (int i = 0; i < blk.Cmds.Count; i++)
                        {
                            var ccmd = blk.Cmds[i] as CallCmd;
                            if (ccmd == null || ccmd.callee != procimpl.Name)
                            {
                                continue;
                            }
                            blk.Cmds[i] = new CallCmd(ccmd.tok, proccopy.Name, ccmd.Ins, ccmd.Outs, ccmd.Attributes);
                        }
                    }
                }

                program.AddTopLevelDeclaration(proccopy);
            }

            return(program);
        }
Esempio n. 33
0
 static void Main() {
     var p = new Program();
     p.PropertyChanged += (s, a) => Console.WriteLine(a.PropertyName);
     p.Name = "abc";
 }
Esempio n. 34
0
 private static void ServerOnClientConnected(object sender, ConnectedClient tcpClient)
 {
     Program.Log(
         $"Client connected: {tcpClient.Client.Client.Handle} - {((IPEndPoint) tcpClient.Client.Client.RemoteEndPoint).Address}");
 }
Esempio n. 35
0
    static void Main(string[] args)
    {
        var p = new Program();

        p.Slove();
    }
Esempio n. 36
0
        private static void ServerOnDataReceived(object sender, Message message)
        {
            try
            {
                var messages = message.MessageString.Split('\u0013');
                foreach (var msg in messages)
                {
                    if (String.IsNullOrWhiteSpace(msg) || String.IsNullOrWhiteSpace(msg.Replace("\0", "")))
                    {
                        continue;
                    }
                    dynamic m = JsonConvert.DeserializeObject(msg);
                    string  t = m.JType?.ToString();
                    if (t != null)
                    {
                        Node node;
                        switch (t)
                        {
                        case "ClientRegistrationInfo":
                            var cri = JsonConvert.DeserializeObject <ClientRegistrationInfo>(msg);
                            //validate the client
                            if (cri.Secret == Settings.TcpSecret)
                            {
                                //we can register
                                var n = new Node {
                                    ClientId = cri.ClientId, TcpClient = message.TcpClient
                                };
                                Bot.Nodes.Add(n);
                                Bot.NodeConnected(n);
                                //n.Broadcast("Registered");
                                Program.Log($"Client registered: {cri.ClientId}");
                            }
                            break;

                        case "NodeInfo":
                            var ni = JsonConvert.DeserializeObject <NodeInfo>(msg);
                            node = Bot.Nodes.FirstOrDefault(x => x.ClientId == ni.ClientId);
                            if (node == null)
                            {
                                node = new Node {
                                    ClientId = ni.ClientId, TcpClient = message.TcpClient
                                };
                                Bot.Nodes.Add(node);
                                Bot.NodeConnected(node);
                            }
                            node.CurrentGames          = ni.CurrentGames;
                            node.CurrentPlayers        = ni.CurrentPlayers;
                            node.DuplicateGamesRemoved = ni.DuplicateGamesRemoved;
                            node.ThreadCount           = ni.ThreadCount;
                            node.TotalGames            = ni.TotalGames;
                            node.TotalPlayers          = ni.TotalPlayers;
                            node.Uptime       = ni.Uptime;
                            node.Games        = ni.Games;
                            node.Version      = ni.Version;
                            node.ShuttingDown = ni.ShuttingDown;
                            if (ni.Version.Contains("5984.20648"))
                            {
                                node.ShuttingDown = true;
                            }
                            break;

                        case "GameEndInfo":
                            var gei = JsonConvert.DeserializeObject <GameEndInfo>(msg);
                            node = Bot.Nodes.FirstOrDefault(x => x.ClientId == gei.ClientId);
                            node?.EndGame(gei);
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Program.Log($"Error in message received: {e.Message}\n{message.MessageString}", true);
            }
        }
Esempio n. 37
0
 static void MarkAllAssumes(Program program, string filename)
 {
     program = SplitOnProcedure(program, "");
     BoogieUtil.PrintProgram(program, filename.Replace(".bpl", "_split_0.bpl"));
 }
Esempio n. 38
0
        private void LogicW()
        {

            var t = TargetSelector.GetTarget(1100, TargetSelector.DamageType.Magical);
            if (!Player.HasBuff("pickacard_tracker"))
            { 
                if (Utils.TickCount - W.LastCastAttemptT > 300)
                {
                    if (R.IsReady() && (Player.HasBuff("destiny_marker") || Player.HasBuff("gate")))
                        W.Cast();
                    else if (t.IsValidTarget() && Program.Combo)
                        W.Cast();
                    else if (Orbwalker.GetTarget() != null)
                    {
                        if (Program.Farm && Orbwalker.GetTarget().Type == GameObjectType.AIHeroClient && Config.Item("harassW", true).GetValue<bool>())
                            W.Cast();
                        else if (Program.LaneClear && (Orbwalker.GetTarget().Type == GameObjectType.obj_AI_Minion || Orbwalker.GetTarget().Type == GameObjectType.obj_AI_Turret) && Config.Item("farmW", true).GetValue<bool>())
                            W.Cast();
                    }
                }
            }
            else 
            {
                if (temp == null)
                    temp = wName;
                else if (temp != wName)
                    cardok = true;

                if (cardok)
                {
                    AIHeroClient orbTarget = null;
                    
                    var getTarget = Orbwalker.GetTarget();
                    if (getTarget != null && getTarget.Type == GameObjectType.AIHeroClient)
                    {
                        orbTarget = (AIHeroClient)getTarget;
                    }

                    if (R.IsReady() && (Player.HasBuff("destiny_marker") || Player.HasBuff("gate")))
                    {
                        FindCard = 1;
                        if (wName == "TwistedFate_Base_W_GoldCard.troy")
                            W.Cast();
                    }
                    else if (Program.Combo && orbTarget.IsValidTarget() &&  W.GetDamage(orbTarget) + Player.GetAutoAttackDamage(orbTarget) > orbTarget.Health)
                    {
                        W.Cast();
                        Program.debug("1" + wName);
                    }
                    else if ( Player.Mana < RMANA + QMANA + WMANA)
                    {
                        FindCard = 2;
                        if (wName == "TwistedFate_Base_W_BlueCard.troy")
                            W.Cast();
                    }
                    else if (Program.Farm && orbTarget.IsValidTarget())
                    {
                        FindCard = 1;
                        if (wName == "TwistedFate_Base_W_BlueCard.troy")
                            W.Cast();
                    }
                    else if (Player.ManaPercent > Config.Item("WredFarm", true).GetValue<Slider>().Value && FarmSpells && Config.Item("farmW", true).GetValue<bool>())
                    {
                        FindCard = 3;
                        if (wName == "TwistedFate_Base_W_RedCard.troy")
                            W.Cast();
                    }
                    else if ((Program.LaneClear || Player.Mana < RMANA + QMANA) && Config.Item("farmW", true).GetValue<bool>())
                    {
                        FindCard = 2;
                        if (wName == "TwistedFate_Base_W_BlueCard.troy")
                            W.Cast();
                    }
                    else if(Program.Combo)
                    {
                        FindCard = 1;
                        if (wName == "TwistedFate_Base_W_GoldCard.troy")
                            W.Cast();
                    }
                }
            }
        }
Esempio n. 39
0
 private static void ServerOnClientDisconnected(object sender, ConnectedClient tcpClient)
 {
     Program.Log($"Client disconnected: {tcpClient.Client.Client.Handle}");
 }