public void WillThrowAnExceptionWithOnlyOneRetry()
		{
			var executor = new Executor(3, new InvalidOperationException());
			var proxy = (Executor)proxyGenerator.CreateClassProxyWithTarget(typeof(Executor), executor, new[] { new RetryInterceptor(1) });
			proxy.Execute();
			Assert.Fail();
		}
Beispiel #2
0
            public override void Eval(Executor exec)
            {
                string sHelpFile = Config.gsDataFolder + "\\help.html";
                StreamWriter sw = new StreamWriter(sHelpFile);
                sw.WriteLine("<html><head><title>Cat Help File</title></head><body>");

                /*
                sw.WriteLine("<h1><a name='level0prims'></a>Level 0 Primitives</h1>");
                OutputTable(sw, "level0", exec);
                sw.WriteLine("<h1><a name='level1prims'></a>Level 1 Primitives</h1>");
                OutputTable(sw, "level1", exec);               
                sw.WriteLine("<h1><a name='level2prims'></a>Level 2 Primitives</h1>");
                OutputTable(sw, "level2", exec);                
                sw.WriteLine("<h1><a name='otherprims'></a>Other Functions</h1>");
                OutputTable(sw, "", exec);
                 */

                sw.WriteLine("<h1>Instructions</h1>");
                OutputAllTable(sw, exec);

                sw.WriteLine("<h1>Definitions</h1>");
                sw.WriteLine("<pre>");
                foreach (Function f in exec.GetAllFunctions())
                {
                    sw.WriteLine(f.GetImplString(true));
                }
                sw.WriteLine("</pre>");

                sw.WriteLine("</body></html>");
                sw.Close();
                Output.WriteLine("saved help file to " + sHelpFile);
            }
Beispiel #3
0
        public static void Bury(Executor exec)
        {
            var count = exec.DataStack.Pop<Tokens.Number>().Value;
            var token = exec.DataStack.Pop<IToken>();

            exec.DataStack.Bury(token, (int) count);
        }
Beispiel #4
0
        public static void Dig(Executor exec)
        {
            var count = exec.DataStack.Pop<Tokens.Number>().Value;
            var token = exec.DataStack.Dig<IToken>((int) count);

            exec.DataStack.Push(token);
        }
 public CharacterHandler(char toHandle, Executor Execute, bool stop)
 {
     this.toHandle = toHandle;
     this.Condition = SimpleCheck;
     this.Execute = Execute;
     this.stop = stop;
 }
Beispiel #6
0
 public IOutputExecutor Create(Settings settings)
 {
     Executor = Executor.WithForsetiConfigurationFile(settings.ForsetiConfigurationFile, verbose: settings.VerboseOutput);
     Executor.ReportWith<Forseti.AppVeyor.Reporter>();
     Executor.RegisterWatcher<Forseti.ConsoleReporter.ConsoleHarnessWatcher>();
     return this;
 }
Beispiel #7
0
 public static void If(Executor exec)
 {
     var code = exec.DataStack.Pop<Tokens.CodeBlock>().Value;
     var condition = exec.DataStack.Pop<Tokens.Number>().Value != 0;
     if (condition)
         exec.CodeStack.PushRange(code);
 }
        /// <param name="options">Compile options</param>
        /// <param name="runInSeparateAppDomain">Should be set to true for production code, but there are issues with NUnit, so tests need to set this to false.</param>
        public bool Compile(CompilerOptions options, bool runInSeparateAppDomain)
        {
            try {
                AppDomain ad = null;
                var actualOut = Console.Out;
                try {
                    Console.SetOut(new StringWriter());	// I don't trust the third-party libs to not generate spurious random messages, so make sure that any of those messages are suppressed.

                    var er = new ErrorReporterWrapper(_errorReporter, actualOut);

                    Executor executor;
                    if (runInSeparateAppDomain) {
                        var setup = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(typeof(Executor).Assembly.Location) };
                        ad = AppDomain.CreateDomain("SCTask", null, setup);
                        executor = (Executor)ad.CreateInstanceAndUnwrap(typeof(Executor).Assembly.FullName, typeof(Executor).FullName);
                    }
                    else {
                        executor = new Executor();
                    }
                    return executor.Compile(options, er);
                }
                finally {
                    if (ad != null) {
                        AppDomain.Unload(ad);
                    }
                    if (actualOut != null) {
                        Console.SetOut(actualOut);
                    }
                }
            }
            catch (Exception ex) {
                _errorReporter.InternalError(ex, null, TextLocation.Empty);
                return false;
            }
        }
Beispiel #9
0
        public static void Redef(Executor exec)
        {
            var to = exec.DataStack.Pop<Tokens.Symbol>().Value;
            var from = exec.DataStack.Pop<Tokens.Symbol>().Value;

            exec.Methods[to] = exec.Methods[from];
        }
Beispiel #10
0
        public static void Def(Executor exec)
        {
            var name = exec.DataStack.Pop<Tokens.Symbol>().Value;
            var code = exec.DataStack.Pop<Tokens.CodeBlock>().Value;

            exec.Methods[name] = new Executor.CodeblockFunction(code.ToList());
        }
Beispiel #11
0
 public static void Swap(Executor exec)
 {
     var a = exec.DataStack.Pop<IToken>();
     var b = exec.DataStack.Pop<IToken>();
     exec.DataStack.Push(a);
     exec.DataStack.Push(b);
 }
Beispiel #12
0
        public void SetUp()
        {
            symbols = A.Fake<Symbols>();
              tokenizer = A.Fake<Tokenizer>();
              executor = A.Fake<Executor>();

              sut = new Interpreter(symbols, tokenizer, executor);
        }
Beispiel #13
0
 public override ICommand Execute()
 {
     using (Executor executor = new Executor(this))
     {
         executor.Execute();
         return this;
     }
 }
Beispiel #14
0
            public override void Eval(Executor exec)
            {
                string s = exec.PopString();

                Executor aux = new Executor(exec);
                aux.Execute(s);
                exec.Push(aux.GetStackAsList());
            }
Beispiel #15
0
        public static void Unpack(Executor exec)
        {
            var block = exec.DataStack.Pop<Tokens.PackedBlock>().Value;
            var count = block.Count;

            exec.DataStack.PushRange(block);
            exec.DataStack.Push(new Tokens.Number(count));
        }
Beispiel #16
0
 public static void PackedResize(Executor exec)
 {
     var size = (int) exec.DataStack.Pop<Tokens.Number>().Value;
     var value = exec.DataStack.Peek<Tokens.PackedBlock>().Value;
     if (value.Count > size)
         value.RemoveRange(value.Count - size - 1, size);
     else if (value.Count < size)
         value.AddRange(Enumerable.Repeat<IToken>(null, size - value.Count));
 }
Beispiel #17
0
        public static void Dive(Executor exec)
        {
            var count = exec.DataStack.Pop<Tokens.Number>().Value;
            var code = exec.DataStack.Pop<Tokens.CodeBlock>().Value;

            exec.DataStack.Dive += (int) count;

            exec.CodeStack.PushRange(new IToken[] { new Tokens.Number(-count), new Tokens.Method(" dive") });
            exec.CodeStack.PushRange(code);
        }
Beispiel #18
0
        public void SetUp()
        {
            instruction = new InstructionTestDouble();
              var registry = new Registry {
            { 0x00, opcode, instruction, AddressingMode.Implied} };

              model = new ProgrammingModel();
              memory = new Memory();
              executor = new Executor(registry, model, memory);
        }
Beispiel #19
0
        public PartialViewExecutor( MethodInfo method )
        {
            var name = method.Name;
              if ( !name.StartsWith( PartialRenderAdapter.partialExecutorMethodPrefix ) )
            throw new InvalidOperationException();
              Name = name.Substring( PartialRenderAdapter.partialExecutorMethodPrefix.Length );
              _parameters = method.GetParameters();

              _executor = CreateExecutor( method );
        }
Beispiel #20
0
 public static void Main(string[] args)
 {
     IExecutor executor = new Executor();
     executor.TaskCompleted += Completed;
     foreach (int i in Enumerable.Range(1, NumTasks))
     {
         executor.ExecuteAsync(i);
     }
     _countdown.Wait();
     Environment.Exit(0);
 }
Beispiel #21
0
        public static void Pack(Executor exec)
        {
            var count = exec.DataStack.Pop<Tokens.Number>().Value;
            List<IToken> Tokens = new List<IToken>();
            for (int i = 0; i < count; i++)
            {
                Tokens.Add(exec.DataStack.Pop<IToken>());
            }

            exec.DataStack.Push(new Tokens.PackedBlock(Tokens));
        }
Beispiel #22
0
        public bool Execute(ISession session, MigrationResources resources)
        {
            _logger.Debug("Initialize database versioner");
            var versioner = new Versioner(session, new Logger<Version>());

            _logger.Debug("Initialize executor");
            var executor = new Executor(session, versioner, new Logger<Executor>());

            _logger.Debug("Execute migrations");
            return executor.Execute(resources);
        }
Beispiel #23
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Enter string to match:");
            string toMatch = Console.ReadLine();
            Console.WriteLine("Start to compute keys, trying to find match for \"{0}\".", toMatch);

            char[] keyspace = new char[] {
                'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
                'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
                'u', 'v', 'w', 'x', 'y', 'z','A','B','C','D','E',
                'F','G','H','I','J','K','L','M','N','O','P','Q','R',
                'S','T','U','V','W','X','Y','Z','1','2','3','4','5',
                '6','7','8','9','0','!','$','#','@','-'
            };
            Executor executor = new Executor(keyspace);

            var iterations = Program.GetEstimatedIterations(keyspace, toMatch.ToCharArray());
            Console.WriteLine("Need to compute {0} keys to match your input.", iterations);
            // just a rough estimation
            Console.WriteLine("Approximate time needed: {0} ms", iterations / 5000);

            char[] lookupKey = toMatch.ToCharArray();
            bool isMatched = false;
            ulong generatedKeyCount = 0;

            Stopwatch stopWatch = Stopwatch.StartNew();

            while(!isMatched) {
                char[] currentKey = executor.ComputeNextKey();
                generatedKeyCount++;
                if (generatedKeyCount % 500000 == 0) {
                    Console.Write('.');
                }
                if (currentKey.Length != lookupKey.Length) {
                    continue;
                }
                for(var i = currentKey.Length - 1; i >= 0; i--) {
                    if (!(currentKey[i] == lookupKey[i])) {
                        break;
                    }
                    if (i == 0) {
                        isMatched = true;
                    }
                }
            }

            stopWatch.Stop();

            Console.WriteLine("Found match.");
            Console.WriteLine("Generated {0} keys, took {1}ms.", generatedKeyCount, stopWatch.ElapsedMilliseconds.ToString());
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
Beispiel #24
0
 public override void Eval(Executor exec)
 {
     Output.WriteLine("Some basic commands to get you started:");
     Output.WriteLine("  \"filename\" #load - loads a source file");
     Output.WriteLine("  [...] #trace - runs a function in trace mode");
     Output.WriteLine("  #test_all - runs all unit tests");
     Output.WriteLine("  [...] #type - shows the type of a function");
     Output.WriteLine("  [...] #metacat - optimizes a function by applying rewriting rules");
     Output.WriteLine("  #defs - lists all loaded commands");
     Output.WriteLine("  \"instruction\" #def - detailed help on an instruction");
     Output.WriteLine("  \"prefix\" #defmatch - describes all instructions starting with prefix");
     Output.WriteLine("  \"tag\" #deftag - outputs all instructions tagged with given tag");
     Output.WriteLine("  #exit - exits the Cat interpreter");
     Output.WriteLine("");
 }
 /// <summary>
 /// 获取分页数据
 /// </summary>
 public DatabaseResultModel<List<TDemoModel>> getListData(TDemoModel searchModel)
 {
     var result = new DatabaseResultModel<List<TDemoModel>>();
     try
     {
         using (databaseConnector = getDatabaseConnector())
         using (databaseExecutor = new Executor(databaseConnector))
         {
             databaseScriptModel = new DatabaseScriptModel();
             databaseScriptModel.command = (new TDemoScript()).getListData(searchModel);
             result.data = databaseExecutor.sqlQueryToList<TDemoModel>(databaseScriptModel);
         }
     }
     catch (Exception ex) { result.exception = ex; }
     return result;
 }
        public DiagnosticIncrementalAnalyzer(
            DiagnosticAnalyzerService owner,
            int correlationId,
            Workspace workspace,
            HostAnalyzerManager hostAnalyzerManager,
            AbstractHostDiagnosticUpdateSource hostDiagnosticUpdateSource)
            : base(owner, workspace, hostAnalyzerManager, hostDiagnosticUpdateSource)
        {
            _correlationId = correlationId;

            _stateManager = new StateManager(hostAnalyzerManager);
            _stateManager.ProjectAnalyzerReferenceChanged += OnProjectAnalyzerReferenceChanged;

            _executor = new Executor(this);
            _compilationManager = new CompilationManager(this);
        }
Beispiel #27
0
	void Awake()
	{
		// インスタンスが存在するなら破棄する
		if (existsInstance)
		{
			Destroy(gameObject);
			return;
		}

		// 存在しない場合
		// 自身が唯一のインスタンスとなる
		existsInstance = true;
		DontDestroyOnLoad(gameObject);

        executor = new Executor();
	}
Beispiel #28
0
        public TestOutcome RunSession(ITestContext assemblyTestContext, MSTestAssembly assemblyTest,
            ITestCommand assemblyTestCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
        {
            DirectoryInfo tempDir = SpecialPathPolicy.For("MSTestAdapter").CreateTempDirectoryWithUniqueName();
            try
            {
                // Set the test results path.  Among other things, the test results path
                // will determine where the deployed test files go.
                string testResultsPath = Path.Combine(tempDir.FullName, "tests.trx");

                // Set the test results root directory.
                // This path determines both where MSTest searches for test files which
                // is used to resolve relative paths to test files in the "*.vsmdi" file.
                string searchPathRoot = Path.GetDirectoryName(assemblyTest.AssemblyFilePath);

                // Set the test metadata and run config paths.  These are just temporary
                // files that can go anywhere on the filesystem.  It happens to be convenient
                // to store them in the same temporary directory as the test results.
                string testMetadataPath = Path.Combine(tempDir.FullName, "tests.vsmdi");
                string runConfigPath = Path.Combine(tempDir.FullName, "tests.runconfig");

                progressMonitor.SetStatus("Generating test metadata file.");
                CreateTestMetadataFile(testMetadataPath,
                    GetTestsFromCommands(assemblyTestCommand.PreOrderTraversal), assemblyTest.AssemblyFilePath);

                progressMonitor.SetStatus("Generating run config file.");
                CreateRunConfigFile(runConfigPath);

                progressMonitor.SetStatus("Executing tests.");
                Executor executor = new Executor(this, assemblyTestContext, assemblyTestCommand);
                TestOutcome outcome = executor.Execute(testMetadataPath, testResultsPath,
                    runConfigPath, searchPathRoot);
                return outcome;
            }
            finally
            {
                try
                {
                    tempDir.Delete(true);
                }
                catch
                {
                    // Ignore I/O exceptions deleting temporary files.
                    // They will probably be deleted by the OS later on during a file cleanup.
                }
            }
        }
Beispiel #29
0
 void OutputAllTable(StreamWriter sw, Executor exec)
 {
     sw.WriteLine("<table width='100%'>");
     int nRow = 0;
     foreach (Function f in exec.GetAllFunctions())
     {
         if (nRow % 5 == 0)
             sw.WriteLine("<tr valign='top'>");
         string sName = Util.ToHtml(f.GetName());
         string s = "<td><a href='#" + sName + "'>" + sName + "</a></td>";
         sw.WriteLine(s);
         if (nRow++ % 5 == 4)
             sw.WriteLine("</tr>");
     }
     if (nRow % 5 != 0) sw.WriteLine("</tr>");
     sw.WriteLine("</table>");
 }
 /// <summary>
 /// 批量更新数据(新增和更新)
 /// </summary>
 public DatabaseResultModel<bool> updateMany(List<TDemoModel> models)
 {
     var result = new DatabaseResultModel<bool>();
     try
     {
         using (databaseConnector = getDatabaseConnector())
         using (databaseExecutor = new Executor(databaseConnector))
         {
             databaseScriptModel = new DatabaseScriptModel();
             databaseScriptModel.command = (new TDemoScript()).updateMany(models);
             executeSqlCommand(new TDemoScript());
             result.data = true;
         }
     }
     catch (Exception ex) { result.exception = ex; result.data = false; }
     return result;
 }
Beispiel #31
0
 public void WhenEnteringForTheElement(ResolvedString text, ActiveElementSelector selector)
 => Executor.Execute(()
                     => WebDriver.Select(selector).Enter(text));
Beispiel #32
0
 public BattleState(IMemoryAPI fface) : base(fface)
 {
     _executor = new Executor(fface);
 }
 public void step_05()
 {
     lid = Other.GetParamFromCurrentUrl("lid");
     lid = lid.Substring(0, lid.IndexOf('#'));
     Executor.ExecuteProcedure("inac.iptv_services_load.job", Environment.InacDb);
 }
Beispiel #34
0
    public Wave(Dictionary <string, System.Object> json)
    {
        canvas = GameObject.Find("Canvas").transform;
        System.Random rand = new System.Random();

        enemies = new List <GameObject> ();
        //note: ints in MiniJSON come out as longs, so must be cast twice
        levelID  = (int)(long)json ["levelID"];
        waveID   = (int)(long)json ["waveID"];
        maxTime  = (int)(long)json ["maxMilliseconds"];
        interval = (int)(long)json ["minimumInterval"];
        List <System.Object> enemyjson = (List <System.Object>)json ["enemies"];

        //step one: create a randomized list of spawn times
        int slots = maxTime / interval;
        //Debug.Log ("wave "+ waveID + " slots: " + slots);
        int occupants = enemyjson.Count;

        //create bool array to randomize
        List <bool> timeslots = new List <bool>();

        for (int i = 0; i < slots; i++)
        {
            if (i < occupants)
            {
                timeslots.Add(true);
            }
            else
            {
                timeslots.Add(false);
            }
        }
        //randomize this array (fisher-yates shuffle)
        for (int i = slots - 1; i > 0; i--)
        {
            int  j    = rand.Next(i + 1);
            bool temp = timeslots[i];
            timeslots[i] = timeslots[j];
            timeslots[j] = temp;
        }
        //make sure one enemy spawns immediately
        if (!timeslots[0])
        {
            for (int i = 1; i < slots; i++)
            {
                if (timeslots[i])
                {
                    timeslots[0] = true;
                    timeslots[i] = false;
                    break;
                }
            }
        }
        //create corresponding array of random-ish long bonuses to positions
        List <long> timeChaos = new List <long>();

        for (int i = 0; i < timeslots.Count; i++)
        {
            timeChaos.Add(0);
        }
        for (int i = 0; i < timeChaos.Count; i++)
        {
            if (timeslots[i])             //if an enemy should spawn in this timeframe,
            //get the previous bonus to make sure you're the min distance away
            {
                long previous = 0;
                if (i > 0)
                {
                    previous = timeChaos[i - 1];
                }
                //create random spawn time within the time slot allotted
                long chaos = rand.Next((int)previous, (int)interval);
                timeChaos[i] = chaos;
            }
        }
        //check to make sure nothing went wrong and timeslots and timechaos are both of length slots
        if (timeslots.Count != slots)
        {
            Debug.Log("timeslots is wrong length! slots is " + slots + " but timeslots length is " + timeslots.Count);
        }
        if (timeChaos.Count != slots)
        {
            Debug.Log("timechaos is wrong length! slots is " + slots + " but timechaos length is " + timeChaos.Count);
        }

        //finally, create final list of spawn times
        List <long> spawntimesInMillis = new List <long>();

        for (int i = 0; i < timeslots.Count; i++)
        {
            if (timeslots[i])
            {
                long spawntime = i * interval;
                spawntime += timeChaos[i];
                spawntimesInMillis.Add(spawntime);
            }
        }
        //for(int i = 0; i < spawntimesInMillis.Count; i++){
        //	Debug.Log ("wave "+ waveID + " spawntime "+i +": " + spawntimesInMillis[i]);
        //}
        //check to make sure nothing went wrong and spawntimes is of length occupants
        if (spawntimesInMillis.Count != enemyjson.Count)
        {
            Debug.Log("spawntimes and enemies don't match! (" + spawntimesInMillis.Count + "/" + enemyjson.Count + ")");
        }

        //shuffle the enemy order (fisher-yates)
        for (int i = enemyjson.Count - 1; i > 0; i--)
        {
            int           j    = rand.Next(i + 1);
            System.Object temp = enemyjson[i];
            enemyjson[i] = enemyjson[j];
            enemyjson[j] = temp;
        }

        for (int i = 0; i < enemyjson.Count; i++)
        {
            System.Object enemy = enemyjson[i];
            Dictionary <string, System.Object> enemydict = (Dictionary <string, System.Object>)enemy;
            //would load from bestiary using (string)enemydict["enemyID"], but no bestiary yet
            //long spawntimeInMillis = (long)enemydict["spawntime"];
            string filename = (string)enemydict["enemyID"];
            int    track    = (int)(long)enemydict["trackID"];
            int    trackpos = 0;
            if (enemydict.ContainsKey("trackpos"))
            {
                trackpos = (int)(long)enemydict["trackpos"];
            }
            //make enemy
            GameObject enemyspawn = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/Enemy")) as GameObject;
            //Debug.Log("we're setting it to the spawn layer");
            //Debug.Log (Dial.spawnLayer == null);
            enemyspawn.transform.SetParent(Dial.spawnLayer, false);
            enemyspawn.SetActive(false);
            Enemy ec = enemyspawn.GetComponent <Enemy>();

            FileLoader fl = new FileLoader("JSONData" + Path.DirectorySeparatorChar + "Bestiary", filename);
            string     actualenemyjson = fl.Read();
            Dictionary <string, System.Object> actualenemydict = Json.Deserialize(actualenemyjson) as Dictionary <string, System.Object>;
            string enemytype = (string)actualenemydict["enemyType"];
            if (enemytype.Equals("Chainers"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Chainer c          = enemyobj.AddComponent <Chainer>() as Chainer;
                float   chaindelay = (float)(double)actualenemydict["delay"];
                c.delay = chaindelay;
                ec      = c;
            }
            else if (enemytype.Equals("TipOfTheSpear"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                TipOfTheSpear tots       = enemyobj.AddComponent <TipOfTheSpear>() as TipOfTheSpear;
                float         chaindelay = (float)(double)actualenemydict["delay"];
                tots.SetDelay(chaindelay);
                tots.leader = true;
                ec          = tots;
            }
            else if (enemytype.Equals("WallOfDoom"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                WallOfDoom wod = enemyobj.AddComponent <WallOfDoom>() as WallOfDoom;
                ec = wod;
            }
            else if (enemytype.Equals("TheDiversion"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Diversion d          = enemyobj.AddComponent <Diversion>() as Diversion;
                float     chaindelay = (float)(double)actualenemydict["delay"];
                d.SetDelay(chaindelay);
                ec = d;
            }
            else if (enemytype.Equals("MeatShield"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                MeatShield ms         = enemyobj.AddComponent <MeatShield>() as MeatShield;
                float      chaindelay = (float)(double)actualenemydict["delay"];
                ms.SetDelay(chaindelay);
                ms.leader = true;
                ec        = ms;
            }
            else if (enemytype.Equals("Splitter"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Splitter s = enemyobj.AddComponent <Splitter>() as Splitter;
                ec = s;
            }
            else if (enemytype.Equals("Blob"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Blob b = enemyobj.AddComponent <Blob>() as Blob;
                ec = b;
            }
            else if (enemytype.Equals("Megasplit"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Megasplit ms = enemyobj.AddComponent <Megasplit>() as Megasplit;
                ec = ms;
            }
            else if (enemytype.Equals("Melder"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Melder m = enemyobj.AddComponent <Melder>() as Melder;
                ec = m;
            }
            else if (enemytype.Equals("BigSplit"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                BigSplit bs = enemyobj.AddComponent <BigSplit>() as BigSplit;
                ec = bs;
            }
            else if (enemytype.Equals("Junior"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Junior j = enemyobj.AddComponent <Junior>() as Junior;
                ec = j;
            }
            else if (enemytype.Equals("Cheater"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Cheater ch = enemyobj.AddComponent <Cheater>() as Cheater;
                ec = ch;
            }
            else if (enemytype.Equals("Spite"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Spite s = enemyobj.AddComponent <Spite>() as Spite;
                ec = s;
            }
            else if (enemytype.Equals("Executor"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Executor s = enemyobj.AddComponent <Executor>() as Executor;
                ec = s;
            }
            else if (enemytype.Equals("Saboteur"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Saboteur s = enemyobj.AddComponent <Saboteur>() as Saboteur;
                ec = s;
            }
            else if (enemytype.Equals("Pusher"))
            {
                GameObject enemyobj = ec.gameObject;
                GameObject.Destroy(enemyobj.GetComponent <Enemy>());
                Pusher s = enemyobj.AddComponent <Pusher>() as Pusher;
                ec = s;
            }

            //give enemy a filename to load from

            ec.SetSrcFileName(filename);
            ec.SetTrackID(track);
            ec.SetTrackLane(trackpos);

            //calculate and set position
            float degrees = (track - 1) * 60 + 30;   //clockwise of y-axis
            degrees += 15 * trackpos;                //negative trackpos is left side, positive is right side, 0 is middle
            degrees  = ((360 - degrees) + 90) % 360; //convert to counterclockwise of x axis
            degrees *= Mathf.Deg2Rad;


            ((RectTransform)enemyspawn.transform).anchoredPosition = new Vector2(Dial.ENEMY_SPAWN_LENGTH * Mathf.Cos(degrees), Dial.ENEMY_SPAWN_LENGTH * Mathf.Sin(degrees));
            //set spawn time
            ec.SetSpawnTime(spawntimesInMillis[i]);

            enemies.Add(enemyspawn);
        }

        /*foreach (System.Object enemy in enemyjson) {
         *      //ec.ConfigureEnemy ();
         * }*/
    }
Beispiel #35
0
 public bool shouldJump(List <string> codeLine, int lineNumber, Executor executor)
 {
     return(executor.labelDict[codeLine[1]] < lineNumber);
 }
Beispiel #36
0
        public static SearchMailboxesResults SeachMailboxes(ISearchPolicy policy, SearchMailboxesInputs input)
        {
            Recorder.Trace(2L, TraceType.InfoTrace, new object[]
            {
                "Controller.SeachMailboxes Input:",
                input,
                "IsLocal:",
                input.IsLocalCall,
                "SearchType:",
                input.SearchType
            });
            Recorder.Record record = policy.Recorder.Start("SearchMailboxes", TraceType.InfoTrace, true);
            ValidateSource.ValidateSourceContext taskContext = new ValidateSource.ValidateSourceContext
            {
                AllowedRecipientTypeDetails = SearchRecipient.RecipientTypeDetail,
                AllowedRecipientTypes       = SearchRecipient.RecipientTypes,
                MinimumVersion           = null,
                RequiredCmdlet           = "New-MailboxSearch",
                RequiredCmdletParameters = "EstimateOnly"
            };
            MailboxInfoCreation.MailboxInfoCreationContext taskContext2 = new MailboxInfoCreation.MailboxInfoCreationContext
            {
                SuppressDuplicates = true,
                MaximumItems       = (int)((input != null && input.SearchType == SearchType.Statistics) ? policy.ThrottlingSettings.DiscoveryMaxStatsSearchMailboxes : ((uint)policy.ExecutionSettings.DiscoveryMaxMailboxes))
            };
            ServerLookup.ServerLookupContext taskContext3 = new ServerLookup.ServerLookupContext();
            CompleteSearchMailbox.CompleteSearchMailboxContext taskContext4 = new CompleteSearchMailbox.CompleteSearchMailboxContext();
            Func <object, string> batchByDatabase = delegate(object item)
            {
                if (!((SearchSource)item).MailboxInfo.IsArchive)
                {
                    return(((SearchSource)item).MailboxInfo.MdbGuid.ToString());
                }
                return(((SearchSource)item).MailboxInfo.ArchiveDatabase.ToString());
            };
            Func <object, string> batchKeyFactory = delegate(object item)
            {
                if (!((SearchSource)item).MailboxInfo.IsRemoteMailbox)
                {
                    return(batchByDatabase(item));
                }
                return("Remote");
            };
            Func <object, string> batchKeyFactory2 = (object item) => ((FanoutParameters)item).GroupId.Uri.ToString();
            Executor executor = new Executor(policy, typeof(InitializeSearchMailbox))
            {
                Concurrency = policy.ExecutionSettings.DiscoverySynchronousConcurrency
            };
            Executor executor2 = executor;

            if (input.IsLocalCall)
            {
                Recorder.Trace(2L, TraceType.InfoTrace, "Controller.SeachMailboxes LocalSearch");
                executor2 = executor2.Chain(new BatchedExecutor(policy, typeof(SearchDatabase))
                {
                    Concurrency     = policy.ExecutionSettings.DiscoveryLocalSearchConcurrency,
                    BatchSize       = (policy.ExecutionSettings.DiscoveryLocalSearchIsParallel ? 1U : policy.ExecutionSettings.DiscoveryLocalSearchBatch),
                    BatchKeyFactory = batchByDatabase
                });
            }
            else
            {
                Recorder.Trace(2L, TraceType.InfoTrace, "Controller.SeachMailboxes Search");
                executor2 = executor2.Chain(new Executor(policy, typeof(DirectoryQueryFormatting))
                {
                    Concurrency = policy.ExecutionSettings.DiscoverySynchronousConcurrency
                }).Chain(new Executor(policy, typeof(DirectoryLookup))
                {
                    Concurrency = policy.ExecutionSettings.DiscoveryADLookupConcurrency
                }).Chain(new Executor(policy, typeof(ValidateSource))
                {
                    Concurrency = policy.ExecutionSettings.DiscoverySynchronousConcurrency,
                    TaskContext = taskContext
                }).Chain(new Executor(policy, typeof(MailboxInfoCreation))
                {
                    Concurrency = policy.ExecutionSettings.DiscoverySynchronousConcurrency,
                    TaskContext = taskContext2
                });
                if (input.SearchType == SearchType.ExpandSources)
                {
                    Recorder.Trace(2L, TraceType.InfoTrace, "Controller.SeachMailboxes ExpandSources");
                    executor2 = executor2.Chain(new BatchedExecutor(policy, typeof(CompleteSourceLookup))
                    {
                        Concurrency     = policy.ExecutionSettings.DiscoverySynchronousConcurrency,
                        BatchKeyFactory = BatchedExecutor.BatchByCount,
                        BatchSize       = policy.ThrottlingSettings.DiscoveryMaxPreviewSearchMailboxes,
                        TaskContext     = input
                    });
                }
                else
                {
                    executor2 = executor2.Chain(new BatchedExecutor(policy, typeof(ServerLookup))
                    {
                        Concurrency     = policy.ExecutionSettings.DiscoveryServerLookupConcurrency,
                        TaskContext     = taskContext3,
                        BatchSize       = policy.ExecutionSettings.DiscoveryServerLookupBatch,
                        BatchKeyFactory = batchKeyFactory
                    }).Chain(new BatchedExecutor(policy, typeof(FanoutSearchMailboxes))
                    {
                        Concurrency     = policy.ExecutionSettings.DiscoveryFanoutConcurrency,
                        BatchSize       = policy.ExecutionSettings.DiscoveryFanoutBatch,
                        BatchKeyFactory = batchKeyFactory2
                    });
                }
            }
            executor2 = executor2.Chain(new Executor(policy, typeof(CompleteSearchMailbox))
            {
                Concurrency = 1U,
                TaskContext = taskContext4
            });
            Recorder.Trace(2L, TraceType.InfoTrace, "Controller.SeachMailboxes Start");
            SearchMailboxesResults result;

            try
            {
                ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Combine(ServicePointManager.ServerCertificateValidationCallback, new RemoteCertificateValidationCallback(ServerToServerEwsCallingContext.CertificateErrorHandler));
                SearchMailboxesResults searchMailboxesResults = executor.Process(input) as SearchMailboxesResults;
                Recorder.Trace(2L, TraceType.InfoTrace, "Controller.SeachMailboxes End");
                if (executor.Context.Failures.Count > 0)
                {
                    Recorder.Trace(2L, TraceType.InfoTrace, "Controller.SeachMailboxes Failures:", executor.Context.Failures.Count);
                    if (searchMailboxesResults == null)
                    {
                        searchMailboxesResults = new SearchMailboxesResults(null);
                    }
                    searchMailboxesResults.AddFailures(executor.Context.Failures);
                }
                policy.Recorder.End(record);
                result = searchMailboxesResults;
            }
            finally
            {
                ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Remove(ServicePointManager.ServerCertificateValidationCallback, new RemoteCertificateValidationCallback(ServerToServerEwsCallingContext.CertificateErrorHandler));
            }
            return(result);
        }
 public void ReceiveExecutor(Executor executor)
 {
     // Not Needed
 }
Beispiel #38
0
 public static void EnableUtilities(IExecutorPlatform utilityPlatform)
 {
     _utility = new Executor(utilityPlatform);
 }
Beispiel #39
0
        public void NullTempFileCollection_Required_Throws()
        {
            string outputName = null, errorName = null;

            Assert.Throws <NullReferenceException>(() => Executor.ExecWaitWithCapture("", null, ref outputName, ref errorName));
        }
Beispiel #40
0
 internal TableQuerySegment <DynamicTableEntity> EndExecuteQuerySegmented(IAsyncResult asyncResult)
 {
     return(Executor.EndExecuteAsync <TableQuerySegment <DynamicTableEntity> >(asyncResult));
 }
Beispiel #41
0
 public ExecutorDelivery(Executor executor, BlinkListener listener)
 {
     mPoster   = executor;
     mListener = listener;
 }
Beispiel #42
0
        public async Task Part6_Custom_Scalar()
        {
            // Create builder and load sdl
            var builder = new SchemaBuilder()
                          .Sdl(@"

                # Custom scalar defined in the SDL
                scalar Uri

                type Query {
                    url: Uri!
                }
                ");

            // Get query type
            builder.GetQuery(out var query);

            // Build schema by binding resolvers from ObjectTypeMap
            var schema = SchemaTools.MakeExecutableSchema(
                builder,
                new ObjectTypeMap
            {
                {
                    query.Name, new FieldResolversMap
                    {
                        {
                            "url", context => ResolveSync.As(new Uri("https://localhost/"))
                        }
                    }
                }
            },
                converters: new Dictionary <string, IValueConverter>()
            {
                // this will add value converter for Uri scalar type
                ["Uri"] = new InlineConverter(
                    serialize: value =>
                {
                    var uri = (Uri)value;
                    return(uri.ToString());
                },
                    parseValue: value => new Uri(value.ToString()),
                    parseLiteral: value =>
                {
                    if (value.Kind == NodeKind.StringValue)
                    {
                        return(new Uri((StringValue)value));
                    }

                    throw new ArgumentOutOfRangeException(
                        nameof(value),
                        $"Cannot coerce Uri from value kind: '{value.Kind}'");
                })
            });


            // execute query
            var result = await Executor.ExecuteAsync(new ExecutionOptions()
            {
                Schema   = schema,
                Document = Parser.ParseDocument(@"{ url }")
            });

            var url = result.Data["url"];

            Assert.Equal("https://localhost/", url.ToString());
        }
Beispiel #43
0
        protected override void Update()
        {
            if (landing)
            {
                do_land(); return;
            }
            switch (stage)
            {
            case Stage.Start:
                VSC_ON(HFlight.Stop);
                if (VSL.LandedOrSplashed || VSL.Altitude.Relative < StartAltitude)
                {
                    CFG.DesiredAltitude = StartAltitude;
                }
                else
                {
                    CFG.DesiredAltitude = VSL.Altitude.Relative;
                }
                if (!VSL.LandedOrSplashed)
                {
                    compute_initial_trajectory();
                }
                break;

            case Stage.GainAltitude:
                Status("Gaining altitude...");
                VSC_ON(HFlight.Level);
                if (VSL.Altitude.Relative > CFG.DesiredAltitude * 0.9f)
                {
                    compute_initial_trajectory();
                }
                break;

            case Stage.Compute:
                double obstacle;
                if (!trajectory_computed())
                {
                    break;
                }
                if (find_biggest_obstacle_ahead(C.StartAltitude, out obstacle))
                {
                    break;
                }
                if (obstacle > 0)
                {
                    StartAltitude      += (float)obstacle + C.ObstacleOffset;
                    CFG.DesiredAltitude = StartAltitude;
                    stage = Stage.GainAltitude;
                }
                else if (VSL.Altitude.Relative < C.StartAltitude - 10)
                {
                    stage = Stage.GainAltitude;
                }
                else if (check_initial_trajectory())
                {
                    accelerate();
                }
                else
                {
                    stage = Stage.Wait;
                }
                break;

            case Stage.Wait:
                if (!string.IsNullOrEmpty(TCAGui.StatusMessage))
                {
                    break;
                }
                accelerate();
                break;

            case Stage.Accelerate:
                CFG.AT.OnIfNot(Attitude.Custom);
                var dV = (trajectory.Orbit.GetFrameVelAtUT(trajectory.StartUT) -
                          VSL.orbit.GetFrameVelAtUT(trajectory.StartUT)).xzy;
                if (VSL.Controls.AlignmentFactor > 0.9 || !CFG.VSCIsActive)
                {
                    CFG.DisableVSC();
                    var dVv = -VSL.Altitude.Absolute;//Vector3d.Dot(dV, VSL.Physics.Up);
                    if (RAD != null)
                    {
                        var dH = VSL.Altitude.Relative - VSL.Altitude.Ahead - VSL.Geometry.H;
                        if (dH < 0)
                        {
                            dVv -= dH / RAD.TimeAhead * 1.1f;
                        }
                    }
                    if (dVv > 0)
                    {
                        fall_correction.I = C.FallCorrectionPID.I * Utils.ClampL(100 / VSL.Altitude.Relative, 1);
                        fall_correction.Update(-VSL.Altitude.Absolute);
                    }
                    else
                    {
                        fall_correction.IntegralError *= Utils.ClampL(1 - fall_correction.I / 10 * TimeWarp.fixedDeltaTime, 0);
                        fall_correction.Update(0);
                    }
//                    Log("dV {}, dVv {}, correction {}, I {}", dV, dVv, fall_correction.Action, fall_correction.I);//debug
                    if (Executor.Execute(dV + fall_correction * VSL.Physics.Up, 10))
                    {
                        Status("Accelerating: " + Colors.Warning.Tag("<b>{0}</b> m/s"),
                               (dV.magnitude - 10).ToString("F1"));
                    }
                    else
                    {
                        fine_tune_approach();
                    }
                }
                else
                {
                    ATC.SetThrustDirW(-dV);
                }
                break;

            case Stage.CorrectTrajectory:
                VSL.Info.Countdown = landing_trajectory.BrakeStartPoint.UT - VSL.Physics.UT - ManeuverOffset;
                if (VSL.Info.Countdown > 0)
                {
                    warp_to_countdown();
                    if (!trajectory_computed())
                    {
                        break;
                    }
                    add_correction_node_if_needed();
                    stage = Stage.Coast;
                }
                else
                {
                    stage = Stage.None;
                    start_landing();
                }
                break;

            case Stage.Coast:
                if (!coast_to_start())
                {
                    stage = Stage.None;
                }
                break;
            }
        }
Beispiel #44
0
 public void WhenSelectingTheElement(ActiveElementSelector selector)
 => Executor.Execute(()
                     => WebDriver.Select(selector).Select());
Beispiel #45
0
 public void WhenSelectingTheElementRow(RowSelectorPrefix row, ActiveElementSelector selector)
 => Executor.Execute(()
                     => WebDriver.ForRow(row).Select(selector).Select());
Beispiel #46
0
 public void WhenEnteringForTheElementRow(RowSelectorPrefix row, ResolvedString text, ActiveElementSelector selector)
 => Executor.Execute(()
                     => WebDriver.ForRow(row).Select(selector).Enter(text));