public HttpClientCore(iRunLog Log, HttpMessageHandler handler) : base(handler) { this.Log = Log; base.DefaultRequestHeaders.UserAgent.ParseAdd("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"); base.DefaultRequestHeaders.Accept.ParseAdd("*/*"); base.DefaultRequestHeaders.AcceptLanguage.ParseAdd("zh-CN,zh;q=0.8"); }
public RunTime(iRunLog log, Dictionary <string, string> parameters) { Log = log; Parameters = parameters; InitKeyword(); var handler = new FunctionsHandler(log, Parameters); innerFuns = new ParamsTransformHandler(handler, log, Parameters); }
public MyRedirectHandler(int maxAutomaticRedirections, HttpMessageHandler innerHandler, CookieContainer cookieContainer, iRunLog log) : base(innerHandler) { this.cookieContainer = cookieContainer; _log = log; if (maxAutomaticRedirections < 0) { throw new ArgumentOutOfRangeException(nameof(maxAutomaticRedirections)); } _maxAutomaticRedirections = maxAutomaticRedirections; }
private static HttpMessageHandler DefaultHabdler(iRunLog Log) { var httpClientHandler = new HttpClientHandler() { AllowAutoRedirect = false, //AutomaticDecompression = System.Net.DecompressionMethods.GZip| System.Net.DecompressionMethods.Deflate }; HttpMessageHandler handler = new MyDecompressionHandler(System.Net.DecompressionMethods.GZip | System.Net.DecompressionMethods.Deflate, httpClientHandler); handler = new MyRedirectHandler(5, handler, httpClientHandler.CookieContainer, Log); return(handler); }
public object runCode(iRunLog log, Dictionary <string, string> Parameters) { SyntaxTree tree = CSharpSyntaxTree.ParseText("int " + code); var root = (CompilationUnitSyntax)tree.GetRoot(); //尝试修改代码插入一些函数,暂时不用 //StringBuilder codeTmp = new StringBuilder(); //foreach (var node in root.ChildNodes().First().ChildNodes().OfType<BlockSyntax>().First().ChildNodes()) { // var stmt1 = SyntaxFactory.ParseStatement("logLine(1);"); // var sss = root.InsertNodesBefore(node,new[] { stmt1 }); // int codeLine = node.GetLocation().GetLineSpan().StartLinePosition.Line + 1; // log.Log(root.ToFullString()); // codeTmp.Append($"logLine({codeLine});"); // codeTmp.Append(node.ToFullString()); //} //log.Log(codeTmp.ToString()); //var cc = root.ChildNodes().FirstOrDefault().ChildNodes().Skip(2).FirstOrDefault().ToFullString().TrimStart('{').TrimEnd('}'); //var result = CSharpScript.RunAsync(root.ChildNodes().First().ChildNodes().OfType<BlockSyntax>().First().ToFullString(), // globals: funLib); if (codeIssues.Any()) { Console.WriteLine("代码存在以下错误,请进行处理:"); foreach (var codeIssue in codeIssues) { string issue = $"严重性:{codeIssue.Severity}, 错误代码: {codeIssue.Id}, 说明: {codeIssue.Message},位置: {codeIssue.Line} 行 {codeIssue.Character}列"; Console.WriteLine(issue); } return(null); } var LRRunTime = new RunTime(log, Parameters); var result = CSharpScript.RunAsync(root.ChildNodes().First().ChildNodes().OfType <BlockSyntax>().First().ToFullString(), globals: LRRunTime); try { return(result.Result.ReturnValue); } catch (Exception e) { return(e); } }
public ParamsTransformHandler(iLRFunctions fun, iRunLog log, Dictionary <string, string> parameters) { Log = log; innerFuns = fun; Parameters = parameters; }
public FunctionsHandler(iRunLog log, Dictionary <string, string> parameters) { Log = log; Parameters = parameters; functionCore = new FunctionsCore(log); }
//private StatisticalDataHandler statisticalDataHandler; public HttpClientCore(iRunLog Log) : this(Log, DefaultHabdler(Log)) { }
public FunctionsCore(iRunLog log) { Log = log; httpClient = new HttpClientCore(Log); }