/// <summary> /// Main method which is to be the starting point /// </summary> /// <param name="args"></param> static void Main(string[] args) { LoggerServiceFactory.SetLoggerService(Log4NetLoggerService.Instance); //this is optional - DefaultLoggerService will be used if not set logger = LoggerServiceFactory.GetLogger(typeof(HiveDataFrameExample)); try { string studioHome = Directory.GetParent("..\\..\\..\\..\\..\\..\\..\\..\\..\\").ToString(); string sparkHome = studioHome + @"\BigDataSDK\SDK\Spark\bin"; string appConfigFile = System.IO.Path.Combine(Directory.GetParent("..\\..\\").ToString(), "App.config"); cSharpRunner = new CSharpRunner(sparkHome, appConfigFile); cSharpRunner.UpdateConfigFile(configFile); // Starting CSharpRunner is essential to execute a C# Spark samples StartCSharpRunner(); if (cSharpRunner.IsCSharpRunnerStarted) { logger.LogInfo("CSharpRunner Started................."); HiveDataFrame(); DisplayEndInfo(); session.SparkContext.Stop(); cSharpRunner.process.Kill(); } else { DisplayEndInfo(); } } catch (Exception ex) { logger.LogError(ex.Message); } }
public async Task ExecuteAsync_ExceptionCode_Compilation_Successfully_Complete() { var compiler = new CSharpCompiler(); var bytes = await compiler.CompileAsync(new BuildingTask("exCode", CSharpSnippets.ExceptionCode)); var runner = new CSharpRunner(); var buildResult = await runner.ExecuteAsync(bytes, Array.Empty<string>()); buildResult.Success.Should().BeFalse(); }
public async Task ExecuteAsync_GoodCode_Compilation_Success() { var compiler = new CSharpCompiler(); var bytes = await compiler.CompileAsync(new BuildingTask("goodCode", CSharpSnippets.GoodCode)); var runner = new CSharpRunner(); var buildResult = await runner.ExecuteAsync(bytes, Array.Empty<string>()); buildResult.Success.Should().BeTrue(); }
public int Run(string[] args) { var app = new CommandLineApplication(false) { Name = "Prospect code generator", Description = "Runs different methods as dnx commands to help you to create some of picies of code", }; var help = app.HelpOption("-?|--help"); var csharp = app.Option("-c|--csharp", "C# code generarion", CommandOptionType.NoValue); var typeScript = app.Option("-t|--typescript", "TypeScript code generarion", CommandOptionType.NoValue); CustomRunners.ForEach(item => { item.Command = app.Option($"-{item.TemplateShort}|--{item.TemplateLong}", item.Description, CommandOptionType.NoValue); }); app.OnExecute(() => { if (csharp.HasValue()) { Runner = new CSharpRunner(); return(Runner.Run()); } if (typeScript.HasValue()) { Runner = new TypeScriptRunner(); return(Runner.Run()); } foreach (var item in CustomRunners) { if (item.Command.HasValue()) { Runner = (BaseRunner)Activator.CreateInstance(item.RunnerType); return(Runner.Run()); } } app.ShowHelp(); return(0); }); return(app.Execute(args)); }
public async Task <JudgeResult> RunSubmissionAsync() { LanguageTypes.Base.Runner runner; switch (Submission.Program.Language) { case Language.C: runner = new CRunner(Contest, Problem, Submission, Box, Provider); break; case Language.Cpp: runner = new CppRunner(Contest, Problem, Submission, Box, Provider); break; case Language.Java: runner = new JavaRunner(Contest, Problem, Submission, Box, Provider); break; case Language.Python: runner = new PythonRunner(Contest, Problem, Submission, Box, Provider); break; case Language.Golang: runner = new GolangRunner(Contest, Problem, Submission, Box, Provider); break; case Language.Rust: runner = new RustRunner(Contest, Problem, Submission, Box, Provider); break; case Language.CSharp: runner = new CSharpRunner(Contest, Problem, Submission, Box, Provider); break; case Language.Haskell: runner = new HaskellRunner(Contest, Problem, Submission, Box, Provider); break; case Language.LabArchive: return(Problem.Type switch { ProblemType.Ordinary => JudgeResult.UnknownLanguageFailure, ProblemType.TestKitLab => await new TestKitRunner(Contest, Problem, Submission, Box, Provider).RunSubmissionAsync(), _ => throw new ArgumentOutOfRangeException() });
public ActionResult TestCode(TestCodeViewModel vm) { //List<String> list = Intelliscents.ShowMethods(vm.CurrentWord); //vm.Suggestions = list; CSharpRunner runner = new CSharpRunner(); //TEMP Commented out vm.AddTestCases(); //string[] input = new string[] { "Test CTS", "Hello World", "Output 3" }; //TEMP Commented Out vm = runner.RunCSharp(vm); return(View(vm)); }
public int Run(string[] args) { var app = new CommandLineApplication(false) { Name = "Prospect code generator", Description = "Runs different methods as dnx commands to help you to create some of picies of code", }; var help = app.HelpOption("-?|--help"); var angular = app.Option("-a|--angular", "Angular code generation", CommandOptionType.NoValue); var csharp = app.Option("-c|--csharp", "C# code generarion", CommandOptionType.NoValue); var typeScript = app.Option("-t|--typescript", "TypeScript code generarion", CommandOptionType.NoValue); app.OnExecute(() => { //if (csharp.HasValue()) //{ var runner = new CSharpRunner(); return(runner.Run()); //} //if (angular.HasValue()) //{ // var runner = new AngularRunner(); // return runner.Run(args); //} //if (typeScript.HasValue()) //{ // var runner = new TypeScriptRunner(); // return runner.Run(); //} //app.ShowHelp(); //return 0; }); return(app.Execute(args)); }
public override void Update() { if (csharp) //C# compiled script { //Initialize thread on first update if (thread == null) { tpause = new ManualResetEvent(false); thread = new Thread(() => { try { CSharpRunner.Run(this, tpause, lines, args, localVars); } catch (CSharpException e) { string errorMessage = "Script '" + file + "' failed to run (" + e.ExceptionType + ")."; LogToConsole(errorMessage); if (owner != null) { SendPrivateMessage(owner, errorMessage); } LogToConsole(e.InnerException); } }); thread.Start(); } //Let the thread run for a short span of time if (thread != null) { tpause.Set(); tpause.Reset(); if (!thread.IsAlive) { UnloadBot(); } } } else //Classic MCC script interpreter { if (sleepticks > 0) { sleepticks--; } else { if (nextline < lines.Length) //Is there an instruction left to interpret? { string instruction_line = lines[nextline].Trim(); // Removes all whitespaces at start and end of current line nextline++; //Move the cursor so that the next time the following line will be interpreted if (instruction_line.Length > 1) { if (instruction_line[0] != '#' && instruction_line[0] != '/' && instruction_line[1] != '/') { instruction_line = Settings.ExpandVars(instruction_line, localVars); string instruction_name = instruction_line.Split(' ')[0]; switch (instruction_name.ToLower()) { case "wait": int ticks = 10; try { ticks = Convert.ToInt32(instruction_line.Substring(5, instruction_line.Length - 5)); } catch { } sleepticks = ticks; break; default: if (!PerformInternalCommand(instruction_line)) { Update(); //Unknown command : process next line immediately } else if (instruction_name.ToLower() != "log") { LogToConsole(instruction_line); } break; } } else { Update(); } //Comment: process next line immediately } } else { //No more instructions to interpret UnloadBot(); } } } }
public async Task ExecuteAsync_Empty_Assembly_Bytes_Should_Return_False_Build_Result() { var runner = new CSharpRunner(); var buildResult = await runner.ExecuteAsync(Array.Empty<byte>(), Array.Empty<string>()); buildResult.Success.Should().BeFalse(); }
//[Ignore("Playground")] public void A() { var converter = new JamToCSharpConverter(); var basePath = new NPath("c:/unity"); var files = new List <NPath>(); files.AddRange(basePath.Combine("Runtime").Files("*.jam", true)); files.AddRange(basePath.Combine("Editor").Files("*.jam", true)); files.AddRange(basePath.Combine("Projects/Jam").Files("*.jam", true)); files.AddRange(basePath.Files("*.jam", false)); files.AddRange(basePath.Combine("PlatformDependent").Files("*.jam", true)); var program = files.Where(f => !f.ToString().Contains("Config")).Select(f => new SourceFileDescription() { File = f.RelativeTo(basePath), Contents = f.ReadAllText() }).ToArray(); var csProgram = converter.Convert(new ProgramDescripton(program)); var jambase = @"C:\jamconverter\external\jamplus\bin\Jambase.jam"; var instructions = new JamRunnerInstructions() { CSharpFiles = csProgram, WorkingDir = new NPath("c:/unity"), JamFileToInvokeOnStartup = jambase.InQuotes(), }; var tempDir = NPath.SystemTemp.Combine("JamRunner"); instructions.WorkingDir = instructions.WorkingDir ?? tempDir; foreach (var f1 in instructions.JamfilesToCreate) { instructions.WorkingDir.Combine(f1.File).WriteAllText(f1.Contents); } CSharpRunner.Compile(csProgram, JamToCSharpConverter.RuntimeDependencies, tempDir.Combine("csharp.exe")); string genericArgs = $"-f {jambase.InQuotes()} -C {instructions.WorkingDir} \"<StandalonePlayer>Runtime/Graphics/Texture2D.obj\" -sPLATFORM=win64 -q -dx"; var csharpOnlyArgs = "-m " + tempDir.Combine("csharp.exe").InQuotes(); var finalArg = genericArgs + " " + csharpOnlyArgs; Console.WriteLine("args: " + JamBinary() + " " + finalArg); throw new Exception(); var args2 = new Shell.ExecuteArgs() { Arguments = finalArg, Executable = JamBinary().ToString() }; var output_cs = DropBox().Combine("output_cs"); Shell.Execute(args2, null, output_cs); //Truncate(output_cs); var args = new Shell.ExecuteArgs() { Arguments = genericArgs, Executable = JamBinary().ToString() }; var output_jam = DropBox().Combine("output_jam"); Shell.Execute(args, null, output_jam); // Truncate(output_jam); }