public static string ToWebString(this Uri u) { var w = new StringBuilder(); try { var url = new URL(u.ToString()); var i = new InputStreamReader(url.openStream()); var reader = new BufferedReader(i); var line = reader.readLine(); while (line != null) { w.AppendLine(line); line = reader.readLine(); } reader.close(); } catch { // oops } return w.ToString(); }
public override void run() { try { string s = NetLoginHandler.getServerId(loginHandler); var url = new URL( (new StringBuilder()).append("http://www.minecraft.net/game/checkserver.jsp?user="******"&serverId=").append(s).toString()); var bufferedreader = new BufferedReader(new InputStreamReader(url.openStream())); string s1 = bufferedreader.readLine(); bufferedreader.close(); if (s1.Equals("YES")) { NetLoginHandler.setLoginPacket(loginHandler, loginPacket); } else { loginHandler.kickUser("Failed to verify username!"); } } catch (Exception exception) { exception.printStackTrace(); } }
/// <summary> /// Releases the unmanaged resources used by this /// <see cref="T:System.IO.TextReader"/> and optionally /// releases the managed resources. /// </summary> /// <param name="disposing"> /// Indicates whether disposale is occuring in the manageable code space. /// </param> protected override void Dispose(bool disposing) { if (disposing) { lock (this) { try { if (m_in != null) { m_in.close(); } } catch (java.io.IOException ex) { throw new IOException(ex.toString(), ex); } finally { m_in = null; m_reader = null; m_lineReader = null; base.Dispose(disposing); } } } else { base.Dispose(disposing); } }
public string DownloadString(Uri u) { var w = new StringBuilder(); try { var url = new java.net.URL(u.ToString()); var i = new java.io.InputStreamReader(url.openStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w.AppendLine(line); line = reader.readLine(); } reader.close(); } catch { // oops } return(w.ToString()); }
// Test the classification result of each map that a user played, // with the data available as if they were playing through it public static void classifyTest(String dataString, String playerID) { String results = ""; try { java.io.StringReader stringReader = new java.io.StringReader(dataString); java.io.BufferedReader buffReader = new java.io.BufferedReader(stringReader); /* NOTE THAT FOR NAIVE BAYES ALL WEIGHTS CAN BE = 1*/ //weka.core.converters.ConverterUtils.DataSource source = new weka.core.converters.ConverterUtils.DataSource("iris.arff"); weka.core.Instances data = new weka.core.Instances(buffReader); //source.getDataSet(); // setting class attribute if the data format does not provide this information // For example, the XRFF format saves the class attribute information as well if (data.classIndex() == -1) data.setClassIndex(data.numAttributes() - 1); weka.classifiers.Classifier cl; for (int i = 3; i < data.numInstances(); i++) { cl = new weka.classifiers.bayes.NaiveBayes(); //cl = new weka.classifiers.trees.J48(); //cl = new weka.classifiers.lazy.IB1(); //cl = new weka.classifiers.functions.MultilayerPerceptron(); ((weka.classifiers.functions.MultilayerPerceptron)cl).setHiddenLayers("12"); weka.core.Instances subset = new weka.core.Instances(data,0,i); cl.buildClassifier(subset); weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(subset); eval.crossValidateModel(cl, subset, 3, new java.util.Random(1)); results = results + eval.pctCorrect(); // For accuracy measurement /* For Mathews Correlation Coefficient */ //double TP = eval.numTruePositives(1); //double FP = eval.numFalsePositives(1); //double TN = eval.numTrueNegatives(1); //double FN = eval.numFalseNegatives(1); //double correlationCoeff = ((TP*TN)-(FP*FN))/Math.Sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)); //results = results + correlationCoeff; if (i != data.numInstances()-1) results = results + ", "; if(i == data.numInstances()-1) Debug.Log("Player: " + playerID + ", Num Maps: " + data.numInstances() + ", AUC: " + eval.areaUnderROC(1)); } } catch (java.lang.Exception ex) { Debug.LogError(ex.getMessage()); } // Write values to file for a matlab read // For accuracy StreamWriter writer = new StreamWriter("DataForMatlab/"+playerID+"_CrossFoldValidations_NeuralNet.txt"); //StreamWriter writer = new StreamWriter("DataForMatlab/"+playerID+"_CrossFoldCorrCoeff.txt"); // For mathews cc writer.WriteLine(results); writer.Close(); Debug.Log(playerID + " has been written to file"); }
public static void Execute(string fileName) { var tagger = new MaxentTagger(TaggerDemo.Model); var ptbTokenizerFactory = PTBTokenizer.factory(new CoreLabelTokenFactory(), "untokenizable=noneKeep"); var r = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "utf-8")); var documentPreprocessor = new DocumentPreprocessor(r); documentPreprocessor.setTokenizerFactory(ptbTokenizerFactory); foreach (List sentence in documentPreprocessor) { var tSentence = tagger.tagSentence(sentence); System.Console.WriteLine(Sentence.listToString(tSentence, false)); } }
public override void run() { var bufferedreader = new BufferedReader(new InputStreamReader(java.lang.System.@in)); string s = null; try { while (!mcServer.serverStopped && MinecraftServer.isServerRunning(mcServer) && (s = bufferedreader.readLine()) != null) { mcServer.addCommand(s, mcServer); } } catch (IOException ioexception) { ioexception.printStackTrace(); } }
public JavaReaderWrapper(java.io.Reader reader) { if (reader == null) { throw new NullReferenceException("reader"); } try { m_reader = new PushbackReader(reader, 1); m_lineReader = new BufferedReader(m_reader); } catch (Exception e) { throw new IOException(e.ToString(), e); } m_in = reader; }
/* Use when the player logs in to initially create the classifier with data from server */ public void InitializeClassifier(String dataString) { try { java.io.StringReader stringReader = new java.io.StringReader(dataString); java.io.BufferedReader buffReader = new java.io.BufferedReader(stringReader); playerData = new weka.core.Instances(buffReader); /* State where in each Instance the class attribute is, if its not already specified by the file */ if (playerData.classIndex() == -1) { playerData.setClassIndex(playerData.numAttributes() - 1); } /* NAIVE BAYES */ //classifier = new weka.classifiers.bayes.NaiveBayes(); /* NEURAL NET */ //classifier = new weka.classifiers.functions.MultilayerPerceptron(); //((weka.classifiers.functions.MultilayerPerceptron)classifier).setHiddenLayers("12"); /* J48 TREE */ //classifier = new weka.classifiers.trees.J48(); /* IB1 NEAREST NEIGHBOUR */ //classifier = new weka.classifiers.lazy.IB1(); /* RANDOM FOREST */ classifier = new weka.classifiers.trees.RandomForest(); classifier.buildClassifier(playerData); Debug.Log("Initialized Classifier"); } catch (java.lang.Exception ex) { Debug.LogError(ex.getMessage()); } }
/* Use when the player logs in to initially create the classifier with data from server */ public void InitializeClassifier(String dataString) { try { java.io.StringReader stringReader = new java.io.StringReader(dataString); java.io.BufferedReader buffReader = new java.io.BufferedReader(stringReader); playerData = new weka.core.Instances(buffReader); /* State where in each Instance the class attribute is, if its not already specified by the file */ if (playerData.classIndex() == -1) playerData.setClassIndex(playerData.numAttributes() - 1); /* NAIVE BAYES */ //classifier = new weka.classifiers.bayes.NaiveBayes(); /* NEURAL NET */ //classifier = new weka.classifiers.functions.MultilayerPerceptron(); //((weka.classifiers.functions.MultilayerPerceptron)classifier).setHiddenLayers("12"); /* J48 TREE */ //classifier = new weka.classifiers.trees.J48(); /* IB1 NEAREST NEIGHBOUR */ //classifier = new weka.classifiers.lazy.IB1(); /* RANDOM FOREST */ classifier = new weka.classifiers.trees.RandomForest(); classifier.buildClassifier(playerData); Debug.Log("Initialized Classifier"); } catch (java.lang.Exception ex) { Debug.LogError(ex.getMessage()); } }
// Test the classification result of each map that a user played, // with the data available as if they were playing through it public static void classifyTest(String dataString, String playerID) { try { java.io.StringReader stringReader = new java.io.StringReader(dataString); java.io.BufferedReader buffReader = new java.io.BufferedReader(stringReader); /* NOTE THAT FOR NAIVE BAYES ALL WEIGHTS CAN BE = 1*/ //weka.core.converters.ConverterUtils.DataSource source = new weka.core.converters.ConverterUtils.DataSource("iris.arff"); weka.core.Instances thisData = new weka.core.Instances(buffReader); //source.getDataSet(); if (thisData.classIndex() == -1) thisData.setClassIndex(thisData.numAttributes() - 1); weka.core.Instances thisUniqueData = new weka.core.Instances(thisData); if (thisUniqueData.classIndex() == -1) thisUniqueData.setClassIndex(thisUniqueData.numAttributes() - 1); thisUniqueData.delete(); if (allUniqueData == null) { allUniqueData = new weka.core.Instances(thisData); if (allUniqueData.classIndex() == -1) allUniqueData.setClassIndex(allUniqueData.numAttributes() - 1); allUniqueData.delete(); } weka.core.InstanceComparator com = new weka.core.InstanceComparator(false); for (int i = 0; i < thisData.numInstances(); i++) { bool dup = false; for (int j = 0; j < allUniqueData.numInstances(); j++) { if (com.compare(thisData.instance(i),allUniqueData.instance(j)) == 0) { Debug.Log("Duplicate found!"); dup = true; break; } } if (!dup) allUniqueData.add(thisData.instance(i)); else dupInstances++; } for (int i = 0; i < thisData.numInstances(); i++) { bool dup = false; for (int j = 0; j < thisUniqueData.numInstances(); j++) { if (com.compare(thisData.instance(i),thisUniqueData.instance(j)) == 0) { Debug.Log("Duplicate found!"); dup = true; break; } } if (!dup) thisUniqueData.add(thisData.instance(i)); else dupInstancesSamePlayer++; } //Debug.Log("All Data Instance Count = " + thisData.numInstances()); //Debug.Log("Unique Data Instance Count = " + thisUniqueData.numInstances()); //Debug.Log("Done!"); } catch (java.lang.Exception ex) { Debug.LogError(ex.getMessage()); } }
private void doTest(String test, TypeInfo typeInfo) { String result = typeToString(typeInfo, ""); var userDir = System.getProperty("user.dir"); var generatedPath = PathHelper.combine(userDir, "Tests/resources/TypeSystemTest/generated"); var generatedDir = new File(generatedPath); if (!generatedDir.exists()) { generatedDir.mkdir(); } var fileWriter = new FileWriter(PathHelper.combine(generatedPath, test + ".txt")); fileWriter.write(result); fileWriter.close(); var expectedPath = PathHelper.combine(userDir, "Tests/resources/TypeSystemTest/expected"); var expectedFile = new File(PathHelper.combine(expectedPath, test + ".txt")); Assert.assertTrue("Expected file not found: " + expectedFile, expectedFile.exists()); var fileReader = new InputStreamReader(new FileInputStream((expectedFile)), Charset.forName("UTF-8")); var reference = readToEnd(fileReader); var genReader = new BufferedReader(new StringReader(result)); var refReader = new BufferedReader(new StringReader(reference)); for (;;) { var genLine = genReader.readLine(); var refLine = refReader.readLine(); if (genLine == null && refLine == null) { break; } Assert.assertEquals(refLine, genLine); } }
public string UploadString(Uri u, string method, string data) { // http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/tip/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java // fails on openJDK why? Console.WriteLine("enter UploadString " + new { u, method }); var w = new StringBuilder(); HttpURLConnection xHttpURLConnection = null; try { #region NSA is that you? intercept? we can only trust pinned off device certs var trustAllCerts = new[] { new localX509TrustManager { } }; SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new localHostnameVerifier { }); #endregion //UploadString getOutputStream //enter checkServerTrusted //enter getAcceptedIssuers //UploadString writeBytes var url = new java.net.URL(u.ToString()); xHttpURLConnection = (HttpURLConnection)url.openConnection(); var https = xHttpURLConnection as HttpsURLConnection; if (https != null) { //Console.WriteLine(new { https }); } //conn.setHostnameVerifier(new localHostnameVerifier { }); xHttpURLConnection.setDoOutput(true); xHttpURLConnection.setDoInput(true); xHttpURLConnection.setInstanceFollowRedirects(false); //conn.setInstanceFollowRedirects(true); xHttpURLConnection.setRequestMethod(method); var xContentType = default(string); try { if (Headers != null) { foreach (string key in Headers.AllKeys) { if (key == "Content-Type") { xContentType = Headers[key]; } xHttpURLConnection.addRequestProperty(key, Headers[key]); } } } catch (Exception e) { //System.Console.WriteLine("ERROR: Failed to write headers. Exception was:" + e.Message); } if (xContentType == null) { xHttpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); xHttpURLConnection.setRequestProperty("charset", "utf-8"); } //conn.setRequestProperty("content-length", "" + data.Length); xHttpURLConnection.setRequestProperty("Content-Length", "" + data.Length); xHttpURLConnection.setUseCaches(false); //Console.WriteLine("UploadString getOutputStream"); var o = xHttpURLConnection.getOutputStream(); //Console.WriteLine("UploadString writeBytes"); // DataOutputStream wr = new DataOutputStream(o); wr.writeBytes(data); //Console.WriteLine("UploadString flush"); wr.flush(); //Console.WriteLine("UploadString close"); wr.close(); //Console.WriteLine("UploadString readLine"); //var i = new java.io.InputStreamReader(url.openStream(), "UTF-8"); var i = new java.io.InputStreamReader(xHttpURLConnection.getInputStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w.AppendLine(line); line = reader.readLine(); } reader.close(); } catch (Exception err) { // 500 ? // = java.net.ProtocolException: Invalid HTTP method: // oops Console.WriteLine("UploadString " + new { err }); } //Console.WriteLine("exit UploadString " + new { conn }); if (xHttpURLConnection != null) { xHttpURLConnection.disconnect(); } return(w.ToString()); }
private static StreamReader ToDotNetReadableStream(this Reader r) { MemoryStream mem = new MemoryStream(); StreamWriter writer = new StreamWriter(mem); try { BufferedReader reader = new BufferedReader(r); while (reader.ready()) { String line = reader.readLine(); if (line != null) { writer.WriteLine(line); } else { break; } } } catch { throw new RdfParseException("Failed to convert the Java Reader into a .Net Stream successfully"); } finally { r.close(); } writer.Flush(); mem.Seek(0, SeekOrigin.Begin); return new StreamReader(mem); }
public static string getFilteredTrace(string stack) { if (BaseTestRunner.showStackRaw()) return stack; StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter((Writer) stringWriter); BufferedReader bufferedReader = new BufferedReader((Reader) new StringReader(stack)); try { string str; while ((str = bufferedReader.readLine()) != null) { if (!BaseTestRunner.filterLine(str)) printWriter.println(str); } goto label_9; } catch (Exception ex) { int num = 2; if (ByteCodeHelper.MapException<Exception>(ex, (ByteCodeHelper.MapFlags) num) == null) throw; } return stack; label_9: return stringWriter.toString(); }
string getStringFromInput(BufferedReader input) { StringBuilder sb = new StringBuilder(); string sTemp; try { sTemp = input.readLine(); while (!(sTemp == "")) { sb.append(sTemp + "\n"); sTemp = input.readLine(); } } catch { sb = new StringBuilder(); } return sb.ToString(); }
public IteratorAnonymousInnerClassHelper(BufferedReader outerInstance) { this.OuterInstance = outerInstance; nextLine = null; }
public void run() { try { serversocket = new ServerSocket(port); serversocket.setReuseAddress(true); while (isRunning) { clientsocket = serversocket.accept(); input = new BufferedReader(new InputStreamReader(clientsocket.getInputStream(), "ISO-8859-2")); output = clientsocket.getOutputStream(); string sAll = getStringFromInput(input); var i0 = sAll.IndexOf(" ", 0); var i1 = sAll.IndexOf(" ", i0 + 1); var path = ((java.lang.String)(object)sAll).substring(i0, i1); if (path.Length > 0) path = ((java.lang.String)(object)path).substring(2, path.Length); var asset = openFileFromAssets(path, mycontext); if (asset != null) { send(asset); } else { #region firstpage string firstpage = "<body>"; firstpage += "<link rel=\"stylesheet\" type=\"text/css\" "; firstpage += "href=\"/foo.css\" />"; firstpage += "<h1>"; firstpage += path; firstpage += "</h1>"; firstpage += "<pre>"; firstpage += sAll; firstpage += "</pre>"; firstpage += "First page! jsc! <a href='/foo.htm'>Next</a>"; firstpage += "Other page! jsc! <a href='/bar.htm'>Other</a>"; var assets = mycontext.getResources().getAssets(); var collection = assets.list(path); foreach (var item in collection) { firstpage += "<pre>"; firstpage += item; firstpage += "</pre>"; firstpage += "<hr />"; } firstpage += "</body>"; send(firstpage); #endregion } input.close(); output.close(); } } catch { } }
private void loadWhiteList() { try { whiteListedIPs.clear(); var bufferedreader = new BufferedReader(new FileReader(whitelistPlayersFile)); for (string s = ""; (s = bufferedreader.readLine()) != null;) { whiteListedIPs.add(s.Trim().ToLower()); } bufferedreader.close(); } catch (Exception exception) { logger.warning((new StringBuilder()).append("Failed to load white-list: ").append(exception).toString()); } }
private void doTest(String test, LambdaExpression lambda) { variables = new ArrayList<VariableExpression>(); labels = new ArrayList<Label>(); switchLabels = new ArrayList<SwitchLabel>(); var result = lambdaToString(lambda); var userDir = System.getProperty("user.dir"); var generatedPath = PathHelper.combine(userDir, "tests/resources/ExpressionTreesTest/generated"); var generatedDir = new File(generatedPath); if (!generatedDir.exists()) { generatedDir.mkdir(); } var fileWriter = new FileWriter(PathHelper.combine(generatedPath, test + ".txt")); fileWriter.write(result); fileWriter.close(); var referencePath = PathHelper.combine(PathHelper.combine(userDir, "tests/resources/ExpressionTreesTest/references"), test + ".txt"); var referenceFile = new File(referencePath); String reference = null; if (referenceFile.exists()) { var fileReader = new InputStreamReader(new FileInputStream((referencePath)), Charset.forName("UTF-8")); reference = readToEnd(fileReader); } else { Assert.fail("No reference for '" + test + "'"); } if (reference != null) { var genReader = new BufferedReader(new StringReader(result)); var refReader = new BufferedReader(new StringReader(reference)); for (;;) { var genLine = genReader.readLine(); var refLine = refReader.readLine(); if (genLine == null && refLine == null) { break; } Assert.assertEquals(refLine, genLine); } } }
private void doTest(String test) { var userDir = System.getProperty("user.dir"); var sourcePath = PathHelper.combine(PathHelper.combine(userDir, "tests/resources/ParseExpressionTest/sources"), test + ".txt"); var fileReader = new InputStreamReader(new FileInputStream((sourcePath)), Charset.forName("UTF-8")); var code = readToEnd(fileReader); text = code.toCharArray(); var parser = new Parser(); var scanner = new SourceCodeScanner(new CodeErrorManager(), text); var expression = parser.parseExpression(scanner); var result = expressionToString(expression); var generatedPath = PathHelper.combine(userDir, "tests/resources/ParseExpressionTest/generated"); var generatedDir = new File(generatedPath); if (!generatedDir.exists()) { generatedDir.mkdir(); } var fileWriter = new FileWriter(PathHelper.combine(generatedPath, test + ".txt")); fileWriter.write(result); fileWriter.close(); var expectedPath = PathHelper.combine(userDir, "tests/resources/ParseExpressionTest/expected"); var expectedFile = new File(PathHelper.combine(expectedPath, test + ".txt")); Assert.assertTrue("Expected file not found: " + expectedFile, expectedFile.exists()); fileReader = new InputStreamReader(new FileInputStream((expectedFile)), Charset.forName("UTF-8")); var reference = readToEnd(fileReader); var genReader = new BufferedReader(new StringReader(result)); var refReader = new BufferedReader(new StringReader(reference)); for (;;) { var genLine = genReader.readLine(); var refLine = refReader.readLine(); if (genLine == null && refLine == null) { break; } Assert.assertEquals(refLine, genLine); } }
protected override void onCreate(Bundle savedInstanceState) { base.onCreate(savedInstanceState); height = getWindowManager().getDefaultDisplay().getHeight(); width = getWindowManager().getDefaultDisplay().getWidth(); this.ToFullscreen(); if (width > height) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // http://stackoverflow.com/questions/8469112/hide-ics-back-home-task-switcher-buttons // http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html // http://stackoverflow.com/questions/9131790/android-lights-out-mode-not-working // http://baroqueworksdev.blogspot.com/2012/02/request-that-visibility-of.html } var r = new System.Random(); var port = r.Next(1024, 32000); uri = "http://" + getLocalIpAddress(); uri += ":"; uri += ((object)(port)).ToString(); this.setTitle(uri); ServerSocket serversocket = null; bool isRunning = true; #region openFileFromAssets Func<string, InputStream> openFileFromAssets = (string spath) => { InputStream value = null; try { value = this.getResources().getAssets().open(spath); } catch { } return value; }; #endregion #region getStringFromInput Func<BufferedReader, string> getStringFromInput = (BufferedReader input) => { StringBuilder sb = new StringBuilder(); string sTemp; try { sTemp = input.readLine(); while (!(sTemp == "")) { sb.append(sTemp + "\n"); sTemp = input.readLine(); } } catch { sb = new StringBuilder(); } return sb.ToString(); }; #endregion #region AtConnection Action<Socket> AtConnection = (clientsocket) => { BufferedReader input = null; OutputStream output = null; try { input = new BufferedReader(new InputStreamReader(clientsocket.getInputStream(), "ISO-8859-2")); output = clientsocket.getOutputStream(); } catch { } #region send_text Action<string> send_text = (s) => { string header = "HTTP/1.1 200 OK\n" + "Connection: close\n" + "Content-type: text/html; charset=utf-8\n"; //"Content-Length: " + s.Length + "\n" + header += "\n"; var w = new OutputStreamWriter(output); try { w.write(header + s); w.flush(); } catch { } }; #endregion #region send_stream Action<InputStream, string> send_stream = (fis, contenttype) => { string header = "HTTP/1.1 200 OK\n"; header += "Expires: Sun, 17 Jan 2038 19:14:07 GMT\n"; header += "Content-type: "; header += contenttype; header += "\n"; //header += "Content-Length: " + fis.available() + "\n" + header += "\n"; try { var w = new OutputStreamWriter(output); w.write(header); w.flush(); sbyte[] buffer = new sbyte[0x10000]; int bytes = 0; bytes = fis.read(buffer); while (bytes != -1) { output.write(buffer, 0, bytes); bytes = fis.read(buffer); } } catch { } }; #endregion new System.Threading.Thread( delegate() { try { string sAll = getStringFromInput(input); var i0 = sAll.IndexOf(" ", 0); var i1 = sAll.IndexOf(" ", i0 + 1); var path = sAll.Substring(i0, i1 - i0); path = path.Replace("%20", " "); if (path.Length > 0) path = path.Substring(2); if (path.Length > 1) { var last = path.Substring(path.Length - 1); if (last == "/") { path = path.Substring(0, path.Length - 1); } } if (this.width > this.height) if (path == "") path = this.ApplicationFile; var asset = openFileFromAssets(path); if (asset != null) { var _get = path; _get += " size: "; _get += ((object)asset.available()).ToString(); Log.i("jsc get", _get); if (path.EndsWith(".gif")) send_stream(asset, "image/gif"); if (path.EndsWith(".htm")) send_stream(asset, "text/html"); else send_stream(asset, "application/octet-stream"); } else { string firstpage = "<body style='padding: 0; margin: 0;'>"; #region AttachQRToElement Action<string, string> AttachQRToElement = (itemuri, Container) => { firstpage += "<script>"; firstpage += "\n"; firstpage += "var i = document.getElementById('"; firstpage += Container; firstpage += "').appendChild( qr.image("; firstpage += "\n"; firstpage += "{value:'"; firstpage += itemuri; firstpage += "'}"; firstpage += "\n"; firstpage += "));"; firstpage += "\n"; firstpage += "</script>"; }; #endregion #region firstpage firstpage += "<script src='/qr.js'></script>"; firstpage += "<center>"; firstpage += "<div style='background-color: black; color: white; padding: 2em;'>"; firstpage += "« Rotate your device to left to <b>launch</b>"; firstpage += "</div>"; firstpage += "<h1>"; firstpage += path; firstpage += "</h1>"; firstpage += "<div id='newdevice'>"; firstpage += "</div>"; AttachQRToElement(this.uri, "newdevice"); firstpage += "<br />"; var ApplicationFileLink = this.uri; ApplicationFileLink += "/"; ApplicationFileLink += this.ApplicationFile; firstpage += "<a"; firstpage += " href='"; firstpage += ApplicationFileLink; firstpage += "' id='ApplicationFile"; firstpage += "'"; firstpage += ">"; firstpage += "<div>"; firstpage += "Connect any other device on the same network to"; firstpage += "</div>"; firstpage += "\n"; firstpage += "<div>"; firstpage += "<code>"; firstpage += this.uri; firstpage += "</code>"; firstpage += "</div>"; firstpage += "</a>"; firstpage += "\n"; firstpage += "<div style='padding: 1em; margin: 0; overflow: hidden;'>"; //ScriptCoreLib.JavaScript.DOM.IStyle.OverflowEnum.hidden var assets = this.getResources().getAssets(); var collection = assets.list(path); var index = 0; #region AtItem Action<string> AtItem = item => { index++; if (!item.Contains(".")) { item += "/"; } firstpage += "<div style='border-top: 0.3em solid black; padding: 1em; '>"; firstpage += "<a"; firstpage += " href='"; firstpage += item; firstpage += "' id='item"; firstpage += ((object)index).ToString(); firstpage += "'"; firstpage += ">"; var path_preview = "assets.preview/"; path_preview += item; path_preview += ".png"; var asset_preview = openFileFromAssets(path_preview); if (asset_preview != null) { firstpage += "<div>"; firstpage += "<img src='"; firstpage += path_preview; firstpage += "' />"; firstpage += "</div>"; } firstpage += "<div>"; firstpage += item; firstpage += "</div>"; firstpage += "\n"; #region WithImage var WithImage = item.EndsWith(".gif"); WithImage |= item.EndsWith(".png"); if (WithImage) { firstpage += "<div>"; firstpage += "<img src='"; firstpage += item; firstpage += "' />"; firstpage += "</div>"; } #endregion firstpage += "</a>"; firstpage += "</div>"; #region WithQR var WithQR = item.EndsWith( ".apk"); if (WithQR) { var ContainerID = "item"; ContainerID += ((object)index).ToString(); var itemuri = this.uri + "/"; itemuri += item; AttachQRToElement(itemuri, ContainerID); } #endregion firstpage += "\n"; }; #endregion foreach (var xitem in collection) { AtItem(xitem); } firstpage += "</center>"; firstpage += "<pre>"; firstpage += sAll; firstpage += "</pre>"; firstpage += "</div>"; firstpage += "</body>"; send_text(firstpage); #endregion } input.close(); output.close(); } catch { } } ).Start(); }; #endregion #region serverThread var serverThread = new System.Threading.Thread( delegate() { try { serversocket = new ServerSocket(port); serversocket.setReuseAddress(true); while (isRunning) { var clientsocket = serversocket.accept(); AtConnection(clientsocket); } } catch { } } ); serverThread.Start(); #endregion #region AtDestroy AtDestroy = delegate { try { if (serversocket != null) serversocket.close(); } catch { } }; #endregion // http://stackoverflow.com/questions/8955228/webview-with-an-iframe-android // http://www.chrisdanielson.com/tag/webviewclient/ this.alertDialog = new AlertDialog.Builder(this).create(); this.progressBar = ProgressDialog.show(this, "Get ready!", "Almost there..." ); #region webview this.webview = new WebView(this); setContentView(webview); webview.getSettings().setBuiltInZoomControls(true); webview.getSettings().setSupportZoom(true); webview.getSettings().setLoadsImagesAutomatically(true); webview.getSettings().setJavaScriptEnabled(true); webview.setInitialScale(ApplicationScale); webview.setWebViewClient(new MyWebViewClient { __this = this }); webview.getSettings().setSupportZoom(false); webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY); //webview.getSettings().setJavaScriptEnabled(true); // no flash in emulator? // works on my phone! // no Flash since android 4.1.0!!! //webview.getSettings().setPluginsEnabled(true); //webview.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON); // OR, you can also load from an HTML string: //var summary = "<html><body>You scored <b>192</b> points.</body></html>"; //webview.loadData(summary, "text/html", null); //Log.i(TAG, "loadUrl"); webview.loadUrl(uri); #endregion }
private void formatInputSectionPart(char[] source, InputSectionPart part, StringBuilder sb, int indent) { var indentSb = new StringBuilder(); for (int i = 0; i < indent; i++) { indentSb.append('.'); } var indentStr = indentSb.toString(); switch (part.InputSectionPartKind) { case Definition: sb.append(indentStr); if (part.Define) { sb.append("#define "); } else { sb.append("#undef "); } sb.append(part.Symbol).append("\r\n"); break; case Line: sb.append(indentStr).append("#line "); if (part.Default) { sb.append("default"); } else if (part.Hidden) { sb.append("hidden"); } else { sb.append(part.Line).append(" "); if (!Helper.isNullOrEmpty(part.Filename)) { sb.append('"').append(part.Filename).append('"'); } } break; case Region: sb.append(indentStr).append("#region"); if (!Helper.isNullOrEmpty(part.StartMessage)) { sb.append(" ").append(part.StartMessage); } sb.append("\r\n"); foreach (var p in part.InputSectionParts) { formatInputSectionPart(source, p, sb, indent + 4); } sb.append(indentStr).append("#endregion"); if (!Helper.isNullOrEmpty(part.EndMessage)) { sb.append(" ").append(part.EndMessage); } sb.append("\r\n"); break; case If: sb.append(indentStr).append("#if expression: ").append(part.ExpressionValue).append(", skipped: ") .append(part.SkippedSection).append("\r\n"); foreach (var p in part.InputSectionParts) { formatInputSectionPart(source, p, sb, indent + 4); } sb.append(indentStr).append("#end\r\n"); break; case Elif: sb.append(indentStr).append("#elif expression: ").append(part.ExpressionValue).append(", skipped: ") .append(part.SkippedSection).append("\r\n"); foreach (var p in part.InputSectionParts) { formatInputSectionPart(source, p, sb, indent + 4); } sb.append(indentStr).append("#end\r\n"); break; case Else: sb.append(indentStr).append("#else skipped: ").append(part.SkippedSection).append("\r\n"); foreach (var p in part.InputSectionParts) { formatInputSectionPart(source, p, sb, indent + 4); } sb.append(indentStr).append("#end\r\n"); break; case Diagnostic: sb.append(indentStr).append((part.Error) ? "#error" : "#warning"); if (!Helper.isNullOrEmpty(part.Message)) { sb.append(" ").append(part.Message); } sb.append("\r\n"); break; case Pragma: sb.append(indentStr).append("#pragma warning ").append((part.Restore) ? "restore" : "disable"); if (part.Warnings.any()) { sb.append(" "); var first = true; foreach (var w in part.Warnings) { if (first) { first = false; } else { sb.append(", "); } sb.append(w); } } sb.append("\r\n"); break; case SourceCode: sb.append(indentStr).append("----\r\n"); var s = new BufferedReader(new StringReader(new String(source, part.Position, part.Length))); var line = ""; while ((line = s.readLine()) != null) { sb.append(indentStr).append(line).append("\r\n"); } sb.append(indentStr).append("----\r\n"); break; } }
public virtual CategoryDataset readCategoryDataset(Reader @in) { DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset(); BufferedReader bufferedReader = new BufferedReader(@in); List list = (List) null; int num = 0; string str = bufferedReader.readLine(); while (str != null) { if (num == 0) list = this.extractColumnKeys(str); else this.extractRowKeyAndData(str, defaultCategoryDataset, list); str = bufferedReader.readLine(); ++num; } return (CategoryDataset) defaultCategoryDataset; }
/// /// <summary> * Main method for testing this class. </summary> /// public static void Main1(string[] options) { string trainFileString; StringBuilder text = new StringBuilder(); SimilarityAnalysis simi = new SimilarityAnalysis(); Reader reader; try { text.Append("\n\nTime Series Similarity Analysis options:\n\n"); text.Append("-t <training file>\n"); text.Append("\tThe name of the training file.\n"); java.util.Enumeration @enum = simi.listOptions(); while (@enum.hasMoreElements()) { Option option = (Option) @enum.nextElement(); text.Append(option.synopsis() + '\n'); text.Append(option.description() + '\n'); } trainFileString = Utils.getOption('t', options); if (trainFileString.Length == 0) { throw new Exception("No training file given!"); } simi.setOptions(options); reader = new BufferedReader(new FileReader(trainFileString)); simi.analyze(new Instances(reader)); System.Console.WriteLine(simi.ToString()); } catch (java.lang.Exception e) { e.printStackTrace(); System.Console.WriteLine("\n" + e.Message + text); } }
public string DownloadString(Uri u) { var w = new StringBuilder(); try { var url = new java.net.URL(u.ToString()); var i = new java.io.InputStreamReader(url.openStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w.AppendLine(line); line = reader.readLine(); } reader.close(); } catch { // oops } return w.ToString(); }
// Test the classification result of each map that a user played, // with the data available as if they were playing through it public static void classifyTest(String dataString, String playerID) { String results = ""; try { java.io.StringReader stringReader = new java.io.StringReader(dataString); java.io.BufferedReader buffReader = new java.io.BufferedReader(stringReader); /* NOTE THAT FOR NAIVE BAYES ALL WEIGHTS CAN BE = 1*/ //weka.core.converters.ConverterUtils.DataSource source = new weka.core.converters.ConverterUtils.DataSource("iris.arff"); weka.core.Instances data = new weka.core.Instances(buffReader); //source.getDataSet(); // setting class attribute if the data format does not provide this information // For example, the XRFF format saves the class attribute information as well if (data.classIndex() == -1) { data.setClassIndex(data.numAttributes() - 1); } weka.classifiers.Classifier cl; for (int i = 3; i < data.numInstances(); i++) { cl = new weka.classifiers.bayes.NaiveBayes(); //cl = new weka.classifiers.trees.J48(); //cl = new weka.classifiers.lazy.IB1(); //cl = new weka.classifiers.functions.MultilayerPerceptron(); ((weka.classifiers.functions.MultilayerPerceptron)cl).setHiddenLayers("12"); weka.core.Instances subset = new weka.core.Instances(data, 0, i); cl.buildClassifier(subset); weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(subset); eval.crossValidateModel(cl, subset, 3, new java.util.Random(1)); results = results + eval.pctCorrect(); // For accuracy measurement /* For Mathews Correlation Coefficient */ //double TP = eval.numTruePositives(1); //double FP = eval.numFalsePositives(1); //double TN = eval.numTrueNegatives(1); //double FN = eval.numFalseNegatives(1); //double correlationCoeff = ((TP*TN)-(FP*FN))/Math.Sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)); //results = results + correlationCoeff; if (i != data.numInstances() - 1) { results = results + ", "; } if (i == data.numInstances() - 1) { Debug.Log("Player: " + playerID + ", Num Maps: " + data.numInstances() + ", AUC: " + eval.areaUnderROC(1)); } } } catch (java.lang.Exception ex) { Debug.LogError(ex.getMessage()); } // Write values to file for a matlab read // For accuracy StreamWriter writer = new StreamWriter("DataForMatlab/" + playerID + "_CrossFoldValidations_NeuralNet.txt"); //StreamWriter writer = new StreamWriter("DataForMatlab/"+playerID+"_CrossFoldCorrCoeff.txt"); // For mathews cc writer.WriteLine(results); writer.Close(); Debug.Log(playerID + " has been written to file"); }
public string UploadString(Uri u, string method, string data) { // http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/tip/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java // fails on openJDK why? Console.WriteLine("enter UploadString " + new { u, method }); var w = new StringBuilder(); HttpURLConnection xHttpURLConnection = null; try { #region NSA is that you? intercept? we can only trust pinned off device certs var trustAllCerts = new[] { new localX509TrustManager{} }; SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, trustAllCerts, new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new localHostnameVerifier { }); #endregion //UploadString getOutputStream //enter checkServerTrusted //enter getAcceptedIssuers //UploadString writeBytes var url = new java.net.URL(u.ToString()); xHttpURLConnection = (HttpURLConnection)url.openConnection(); var https = xHttpURLConnection as HttpsURLConnection; if (https != null) { //Console.WriteLine(new { https }); } //conn.setHostnameVerifier(new localHostnameVerifier { }); xHttpURLConnection.setDoOutput(true); xHttpURLConnection.setDoInput(true); xHttpURLConnection.setInstanceFollowRedirects(false); //conn.setInstanceFollowRedirects(true); xHttpURLConnection.setRequestMethod(method); var xContentType = default(string); try { if (Headers != null) { foreach (string key in Headers.AllKeys) { if (key == "Content-Type") { xContentType = Headers[key]; } xHttpURLConnection.addRequestProperty(key, Headers[key]); } } } catch (Exception e) { //System.Console.WriteLine("ERROR: Failed to write headers. Exception was:" + e.Message); } if (xContentType == null) { xHttpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); xHttpURLConnection.setRequestProperty("charset", "utf-8"); } //conn.setRequestProperty("content-length", "" + data.Length); xHttpURLConnection.setRequestProperty("Content-Length", "" + data.Length); xHttpURLConnection.setUseCaches(false); //Console.WriteLine("UploadString getOutputStream"); var o = xHttpURLConnection.getOutputStream(); //Console.WriteLine("UploadString writeBytes"); // DataOutputStream wr = new DataOutputStream(o); wr.writeBytes(data); //Console.WriteLine("UploadString flush"); wr.flush(); //Console.WriteLine("UploadString close"); wr.close(); //Console.WriteLine("UploadString readLine"); //var i = new java.io.InputStreamReader(url.openStream(), "UTF-8"); var i = new java.io.InputStreamReader(xHttpURLConnection.getInputStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w.AppendLine(line); line = reader.readLine(); } reader.close(); } catch (Exception err) { // 500 ? // = java.net.ProtocolException: Invalid HTTP method: // oops Console.WriteLine("UploadString " + new { err }); } //Console.WriteLine("exit UploadString " + new { conn }); if (xHttpURLConnection != null) xHttpURLConnection.disconnect(); return w.ToString(); }
private void readBannedPlayers() { try { bannedPlayers.clear(); var bufferedreader = new BufferedReader(new FileReader(bannedPlayersFile)); for (string s = ""; (s = bufferedreader.readLine()) != null;) { bannedPlayers.add(s.Trim().ToLower()); } bufferedreader.close(); } catch (Exception exception) { logger.warning((new StringBuilder()).append("Failed to load ban list: ").append(exception).toString()); } }
// Test the classification result of each map that a user played, // with the data available as if they were playing through it public static void classifyTest(String dataString, String playerID) { try { java.io.StringReader stringReader = new java.io.StringReader(dataString); java.io.BufferedReader buffReader = new java.io.BufferedReader(stringReader); /* NOTE THAT FOR NAIVE BAYES ALL WEIGHTS CAN BE = 1*/ //weka.core.converters.ConverterUtils.DataSource source = new weka.core.converters.ConverterUtils.DataSource("iris.arff"); weka.core.Instances thisData = new weka.core.Instances(buffReader); //source.getDataSet(); if (thisData.classIndex() == -1) { thisData.setClassIndex(thisData.numAttributes() - 1); } weka.core.Instances thisUniqueData = new weka.core.Instances(thisData); if (thisUniqueData.classIndex() == -1) { thisUniqueData.setClassIndex(thisUniqueData.numAttributes() - 1); } thisUniqueData.delete(); if (allUniqueData == null) { allUniqueData = new weka.core.Instances(thisData); if (allUniqueData.classIndex() == -1) { allUniqueData.setClassIndex(allUniqueData.numAttributes() - 1); } allUniqueData.delete(); } weka.core.InstanceComparator com = new weka.core.InstanceComparator(false); for (int i = 0; i < thisData.numInstances(); i++) { bool dup = false; for (int j = 0; j < allUniqueData.numInstances(); j++) { if (com.compare(thisData.instance(i), allUniqueData.instance(j)) == 0) { Debug.Log("Duplicate found!"); dup = true; break; } } if (!dup) { allUniqueData.add(thisData.instance(i)); } else { dupInstances++; } } for (int i = 0; i < thisData.numInstances(); i++) { bool dup = false; for (int j = 0; j < thisUniqueData.numInstances(); j++) { if (com.compare(thisData.instance(i), thisUniqueData.instance(j)) == 0) { Debug.Log("Duplicate found!"); dup = true; break; } } if (!dup) { thisUniqueData.add(thisData.instance(i)); } else { dupInstancesSamePlayer++; } } //Debug.Log("All Data Instance Count = " + thisData.numInstances()); //Debug.Log("Unique Data Instance Count = " + thisUniqueData.numInstances()); //Debug.Log("Done!"); } catch (java.lang.Exception ex) { Debug.LogError(ex.getMessage()); } }
public string UploadString(Uri u, string method, string data) { var w = new StringBuilder(); HttpURLConnection conn = null; try { var url = new java.net.URL(u.ToString()); conn = (HttpURLConnection)url.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); conn.setInstanceFollowRedirects(false); conn.setRequestMethod(method); conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); conn.setRequestProperty("charset", "utf-8"); conn.setRequestProperty("content-length", "" + data.Length); conn.setUseCaches(false); try { if (Headers != null) { foreach (string key in Headers.AllKeys) { conn.addRequestProperty(key, Headers[key]); } } } catch (Exception e) { //System.Console.WriteLine("ERROR: Failed to write headers. Exception was:" + e.Message); } DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); wr.writeBytes(data); wr.flush(); wr.close(); //var i = new java.io.InputStreamReader(url.openStream(), "UTF-8"); var i = new java.io.InputStreamReader(conn.getInputStream(), "UTF-8"); var reader = new java.io.BufferedReader(i); // can't we just read to the end? var line = reader.readLine(); while (line != null) { w.AppendLine(line); line = reader.readLine(); } reader.close(); } catch { // oops } if (conn != null) { conn.disconnect(); } return(w.ToString()); }
public void ShellAsync(string e, Action<string> y) { #if AndroidShellAsync // http://www.android.pk/blog/general/launch-app-through-adb-shell/ // am start -a android.intent.action.MAIN -n com.android.settings/.Settings // am start tel:210-385-0098 // am start -a android.intent.action.CALL tel:245007 // am start -a android.intent.action.SENDTO "sms:5245007" -e "sms_body" "heyy" && input keyevent 22 && input keyevent 66 // am start -a android.intent.action.SENDTO -d sms:1234567890 --es sms_body ohai --ez exit_on_sent true // am start -a android.intent.action.SENDTO -d smsto:245007 --es sms_body ":*" --ez exit_on_sent true && am start -a android.intent.action.SENDTO -d sms:5245007 --es sms_body ":*" --ez exit_on_sent true && input keyevent 22 && input keyevent 66 // pm list packages // pm list packages -f //http://stackoverflow.com/questions/11201659/android-adb-shell-dumpsys-tool // am start -S -e sms_body 'your message body' \ //-e address receiver -t 'vnd.android-dir/mms-sms' \ //com.android.mms/com.android.mms.ui.ComposeMessageActivity \ //&& adb shell input keyevent 66 //am start -n com.google.android.youtube/.PlayerActivity -d http://www.youtube.com/watch?v=MTT-crZBB0k // http://stackoverflow.com/questions/7095470/android-read-send-text-messages-on-ubuntu // System.InvalidOperationException: Sequence contains more than one element //at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source) //at jsc.Languages.Java.JavaCompiler.GetArrayEnumeratorType() in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.overrride.cs:line 52 //at jsc.Languages.Java.JavaCompiler.GetImportTypes(Type t, Boolean bExcludeJavaLang) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.WriteImportTypes.cs:line 363 //at jsc.Languages.Java.JavaCompiler.WriteImportTypes(Type ContextType) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.WriteImportTypes.cs:line 22 //at jsc.Languages.Java.JavaCompiler.CompileType(Type z) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\JavaCompiler.CompileType.cs:line 43 //at jsc.Languages.CompilerJob.<>c__DisplayClass1a.<CompileJava>b__17(Type xx) in x:\jsc.internal.svn\compiler\jsc\Languages\Java\CompilerJob.cs:line 120 // IsArrayEnumerator: ScriptCoreLib.Shared.BCLImplementation.System.__SZArrayEnumerator`1, ScriptCoreLibAndroid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null //IsArrayEnumerator: ScriptCoreLib.Shared.BCLImplementation.System.__SZArrayEnumerator`1, ScriptCoreLibJava, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null try { // http://stackoverflow.com/questions/9062182/android-icmp-ping var p = new ProcessBuilder(new[] { "sh" }).redirectErrorStream(true).start(); var os = new DataOutputStream(p.getOutputStream()); //os.writeBytes(e + '\n'); os.writeBytes(e + "\n"); os.flush(); // Close the terminal os.writeBytes("exit\n"); os.flush(); // read ping replys var reader = new BufferedReader(new InputStreamReader(p.getInputStream())); string line = reader.readLine(); while (line != null) { y(line); line = reader.readLine(); } } catch (System.Exception ex) { y("AndroidShellAsync error: " + new { ex.Message }); } #elif ShellAsync try { var p = System.Diagnostics.Process.Start( new ProcessStartInfo("cmd") { //ex = {"The Process object must have the UseShellExecute property set to false in order to redirect IO streams."} UseShellExecute = false, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true } ); y("pid: " + p.Id); y(""); //ex = {"Timeouts are not supported on this stream."} //p.StandardOutput.BaseStream.ReadTimeout = 4000; //p.StandardError.BaseStream.ReadTimeout = 4000; var StandardOutput = ""; var StandardError = ""; p.StandardInput.WriteLine(e); p.StandardInput.WriteLine("exit"); var ww = new AutoResetEvent(false); #region timeout var rr = new System.Threading.Thread( delegate() { StandardOutput = p.StandardOutput.ReadToEnd(); StandardError = p.StandardError.ReadToEnd(); ww.Set(); } ); rr.Start(); #endregion #region timeout new System.Threading.Thread( delegate() { System.Threading.Thread.Sleep(5000); if (rr.IsAlive) { rr.Abort(); } ww.Set(); //ex = {"Process must exit before requested information can be determined."} if (p.HasExited) return; p.Kill(); } ).Start(); #endregion System.Threading.Thread.Yield(); ww.WaitOne(); y(StandardOutput); y(StandardError); y(""); y("exit: " + p.ExitCode); } catch (System.Exception ex) { Debugger.Break(); } finally { y = null; } #else y("ShellAsync not implemented."); #endif }