protected override void OnCreateManager() { m_BuildPhysicsWorldSystem = World.GetOrCreateManager <BuildPhysicsWorld>(); m_StepPhysicsWorldSystem = World.GetOrCreateManager <StepPhysicsWorld>(); m_EndFramePhysicsSystem = World.GetOrCreateManager <EndFramePhysicsSystem>(); m_DebugStreamSystem = World.GetOrCreateManager <DebugStream>(); }
public override IEnumerable <Row> Process(RowSet input_rowset, Row output_row, string[] args) { NameFilter name_filter = new NameFilter(); foreach (Row input_row in input_rowset.Rows) { string input_string = input_row["Directors"].String; string[] input_split = input_string.Split(name_filter.SplitChars, StringSplitOptions.RemoveEmptyEntries); List <string> input_splited = new List <string>(input_split); //input_splited.Add(input_string); foreach (string item in input_splited) { string name = item.Trim(); if (name_filter.isAppropriateLanguage(name) && name_filter.isAppropriateLength(name, 1, 6) && !name_filter.isNoiseEntity(name)) //if (name_filter.isAppropriateLanguage(name) && !name_filter.isNoiseEntity(name)) { output_row["Directors"].Set(name); yield return(output_row); } else { // for debug output_row["Directors"].Set("000DirectorNameProcessor" + name); //yield return output_row; DebugStream.WriteLine(output_row.ToString()); } } } }
public void TestReadNCR(string sDebugStream, long ibStart, long ibLim, long lcbSwapBuffer, string[] rgsNCRExpected, string[] rgsNonNCRExpected, long ibSeekExpected, string sExpectedException) { DebugStream stm = DebugStream.StmCreateFromString(sDebugStream + "aaaa\n"); BufferedStreamEx stmx = new BufferedStreamEx(stm, ibStart, ibLim, lcbSwapBuffer); TestDelegate t = () => { // to do this test, we will construct the string before and after NCRs. a null // in the expected string is where an NCR is expected. StringBuilder sb = new StringBuilder(); byte b; int iNonNCR = 0; int iNCR = 0; bool fSkipNextNCRStart = false; // this means we have tried this &, and its not an NCR while (stmx.ReadByte(out b) != SwapBuffer.ReadByteBufferState.SourceDataExhausted) { if (fSkipNextNCRStart || b != '&') { sb.Append((char)b); fSkipNextNCRStart = false; continue; } // read the possible NCR string sAcceptedNCR; if (!stmx.ReadNCR(out sAcceptedNCR)) { fSkipNextNCRStart = true; continue; } // we have an NCR! // confirm we match the before NCR, the null placeholder for the NCR, and the NCR Assert.AreEqual(rgsNonNCRExpected[iNonNCR++], sb.ToString()); Assert.AreEqual(rgsNonNCRExpected[iNonNCR++], null); // there should be a null Assert.AreEqual(rgsNCRExpected[iNCR++], sAcceptedNCR); sb.Clear(); // and continue } // at this point there can't be any NCR's Assert.AreEqual(rgsNCRExpected.Length, iNCR); Assert.AreEqual(rgsNonNCRExpected[iNonNCR], sb.ToString()); Assert.AreEqual(ibSeekExpected, stmx.Position()); }; if (sExpectedException != null) { RunTestExpectingException(t, sExpectedException); } else { t(); } }
public override IEnumerable <Row> Process(RowSet input_rowset, Row output_row, string[] args) { NameFilter name_filter = new NameFilter(); foreach (Row input_row in input_rowset.Rows) { string input_string = input_row["CountryName"].String; string[] input_split = input_string.Split(name_filter.SplitChars); foreach (string item in input_split) { string name = item.Trim(); if (NameFilter.isAppropriateLanguage(name) && NameFilter.isAppropriateLength(name, 1, 6)) { output_row["CountryName"].Set(name); yield return(output_row); } else { // for debug output_row["CountryName"].Set("000CountryNameProcessor" + name); //yield return output_row; DebugStream.WriteLine(output_row.ToString()); } } } }
/* * Try a SSLv2 connection. An error while opening the TCP * connection is reported as an exception. For all other errors, * null is returned. */ SSL2 DoConnectV2() { Stream ns = null; try { ns = OpenConnection(); if (readTimeout > 0) { RTStream rns = new RTStream(ns); rns.RTimeout = readTimeout; ns = rns; } if (debugLog != null) { debugLog.WriteLine("==========================================================================="); ns = new DebugStream(ns, debugLog); } SSL2 v2 = SSL2.TestServer(ns); if (v2 != null) { rp.SSLv2CipherSuites = v2.CipherSuites; rp.SetSSLv2Certificate(v2.Certificate); } return(v2); } finally { try { if (ns != null) { ns.Close(); } } catch (Exception) { // ignored } } }
/// <summary> /// Write the JSON message to the output stream. /// </summary> /// <param name="message"> /// The message to write. /// </param> private void WriteJsonMessage(string message) { // Build the header message. var header = string.Format("Content-Length: {0}{1}{2}{1}{2}", message.Length, (char)0x0D, (char)0x0A); var headerData = Encoding.UTF8.GetBytes(header); SourceStream.Write(headerData, 0, headerData.Length); // Write the body data. var bodyData = Encoding.UTF8.GetBytes(message); SourceStream.Write(bodyData, 0, bodyData.Length); SourceStream.Flush(); // debug the new message. if (DebugStream != null) { lock (DebugStream) { DebugStream.WriteLine("*****************************************"); DebugStream.WriteLine(" Direction: {0}", Direction); DebugStream.WriteLine(" Timestamp: {0}", DateTime.Now); DebugStream.WriteLine("*****************************************"); DebugStream.WriteLine(message); DebugStream.WriteLine("*****************************************"); DebugStream.Flush(); } } }
private void WriteDebugLog(DebugStream stream, string message) { if (_debugLogger == null) { return; } _debugLogger.Log(stream, message); }
public void Standard() { using (StringWriter writer = new StringWriter()) { using (TextWriterTraceListener listener = new TextWriterTraceListener(writer)) { Debug.Listeners.Add(listener); DebugStream output = new DebugStream(); output.Standard("this is a standard message"); } Assert.AreEqual("this is a standard message", writer.ToString().Trim()); } }
public void Error() { using (StringWriter writer = new StringWriter()) { using (TextWriterTraceListener listener = new TextWriterTraceListener(writer)) { Debug.Listeners.Add(listener); DebugStream output = new DebugStream(); output.Error("this is an error"); } Assert.AreEqual("ERROR:this is an error", writer.ToString().Trim()); } }
/*---------------------------------------------------------------------------- * %%Function: TestReadLineWithStreamEndingAtFileLimit * %%Qualified: TCore.StreamEx.BufferedStreamEx.TestReadLineWithStreamEndingAtFileLimit * %%Contact: rlittle * * ----------------------------------------------------------------------------*/ public static void TestReadLineWithStreamEndingAtFileLimit(string sDebugStream, long ibStart, long ibLim, long lcbSwapBuffer, string[] rgsExpected, long ibSeekExpected, string sExpectedException) { DebugStream stm = DebugStream.StmCreateFromString(sDebugStream); BufferedStreamEx stmx = new BufferedStreamEx(stm, ibStart, ibLim, lcbSwapBuffer); TestDelegate t = () => { foreach (string s in rgsExpected) { Assert.AreEqual(s, stmx.ReadLine()); } Assert.AreEqual(ibSeekExpected, stmx.Position()); }; if (sExpectedException != null) { RunTestExpectingException(t, sExpectedException); } else { t(); } }
protected override void OnCreate() { m_BuildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>(); m_StepPhysicsWorld = World.GetOrCreateSystem <StepPhysicsWorld>(); m_DebugStreamSystem = World.GetOrCreateSystem <DebugStream>(); }
protected override void OnCreate() { m_BuildPhysicsWorldSystem = World.GetOrCreateSystem <BuildPhysicsWorld>(); m_EndFramePhysicsSystem = World.GetOrCreateSystem <EndFramePhysicsSystem>(); m_DebugStreamSystem = World.GetOrCreateSystem <DebugStream>(); }
/* * Try a connection with the current test settings. Connection * errors get through as exceptions. Other errors result in a * null returned value. If the handshake failed after the * ServerHello, then a non-null object is returned. */ SSLTestResult DoConnect() { Stream ns = null; try { ns = OpenConnection(); if (verbose) { Console.Write("."); } if (!gotSSLAnswer && readTimeout > 0) { RTStream rns = new RTStream(ns); rns.RTimeout = readTimeout; ns = rns; } if (debugLog != null) { debugLog.WriteLine("==========================================================================="); ns = new DebugStream(ns, debugLog); } try { bool hasECExt = tb.SupportedCurves != null && tb.SupportedCurves.Length > 0; SSLRecord rec = new SSLRecord(ns); SSLTestResult tr = tb.RunTest(rec); gotSSLAnswer = true; if (tr != null) { if (tr.DeflateCompress) { serverCompress = true; } AddServerChain(tr.CertificateChain); AddServerTime(tr.TimeMillis); AddServerDHSize(tr.DHSize); AddServerECSize(tr.ECSize, hasECExt); AddServerNamedCurve(tr.Curve); if (tr.CurveExplicitPrime) { curveExplicitPrime = tr.ECSize; } else if (tr.CurveExplicitChar2) { curveExplicitChar2 = tr.ECSize; } if (tr.UnknownSKE) { unknownSKE = true; } if (tr.RenegotiationInfo != null) { doesRenego = true; } if (tr.DoesEtM) { doesEtM = true; } } return(tr); } catch (SSLAlertException ae) { gotSSLAnswer = true; sslAlert = ae.Alert; return(null); } catch (ReadTimeoutException) { gotReadTimeout = true; return(null); } catch (Exception) { return(null); } } finally { try { if (ns != null) { ns.Close(); } } catch (Exception) { // ignored } } }
protected override void OnCreateManager() { m_StepWorld = World.GetOrCreateManager <StepPhysicsWorld>(); m_DebugStreamSystem = World.GetOrCreateManager <DebugStream>(); }
// Compares two strings using the specified operator public static bool CompareStringProperty(GoalProperty <string> prop, string value, bool compareUrls = false) { if (prop == null || String.IsNullOrWhiteSpace(prop.PropertyValue) || String.IsNullOrWhiteSpace(value)) { return(false); } var propertyValue = prop.PropertyValue; value = value.Trim(); if ((int)prop.ComparisonOperator == 7) { // Hard coded & int casted because we will soon be dropping Conman + rewriting/merging the Operator enums // 7: Operator value denoting "Contains" eg does the destination url contain the given property value return(value.IndexOf(propertyValue, StringComparison.OrdinalIgnoreCase) != -1); } if (prop.ComparisonOperator == GoalComparisonOperator.RegularExpression) { if (!prop.RegexAssigned) { prop.RegexAssigned = true; var strippedPropertyValue = propertyValue.TrimEnd('\\', '/'); if (strippedPropertyValue.StartsWith("*")) { // One common mistake in the customer defined url regular expression is forgetting to add the '.' before '*'. // So ".*thankyou.html" is correct but "*thankyou.html" will throw exception during new Regex operation. strippedPropertyValue = "." + strippedPropertyValue; } else if (strippedPropertyValue.StartsWith("?")) { // One common mistake in the customer defined url regular expression is forgetting to add the '\' before '?'. // So "\?thankyou.html" is correct but "?thankyou.html" will throw exception during new Regex operation. strippedPropertyValue = @"\" + strippedPropertyValue; } if (strippedPropertyValue.Contains(@"\_")) { // Another common mistake in the customer defined url regular expression is that they use '\_' to represent '_', // while in C# _ is not a escape character. strippedPropertyValue = strippedPropertyValue.Replace(@"\_", @"_"); strippedPropertyValue = strippedPropertyValue.Replace(@"\_", @"\\_"); // We are seeing an "\\_" case and should not replace this one. } try { // Original code first try non-trimmed first then trimmed, which is unnecessary. We can try directly the trimmed. prop.Regex = new Regex(strippedPropertyValue, RegexOptions.IgnoreCase, RegexTimeOut); } catch (ArgumentException) { // TODO: UI needs to validate the regex // DebugStream.WriteLine("Failed to parse regex " + propertyValue); return(false); } } if (prop.Regex != null) { try { return(prop.Regex.IsMatch(value)); } catch (RegexMatchTimeoutException) { DebugStream.WriteLine("Timeout occured for " + propertyValue + " when matching " + value); } } return(false); } var result = false; switch (prop.ComparisonOperator) { case GoalComparisonOperator.EqualsTo: result = String.Equals(value, propertyValue, StringComparison.OrdinalIgnoreCase); break; case GoalComparisonOperator.BeginsWith: result = value.StartsWith(propertyValue, StringComparison.OrdinalIgnoreCase); break; } if (!result && compareUrls) { // If the original strings do not match, try matching pure URLs (without http or www) var strippedPropertyValue = StripHeaders(propertyValue.TrimEnd('/')); var strippedValue = StripHeaders(value.TrimEnd('/')); switch (prop.ComparisonOperator) { case GoalComparisonOperator.EqualsTo: result = String.Equals(strippedValue, strippedPropertyValue, StringComparison.OrdinalIgnoreCase); break; case GoalComparisonOperator.BeginsWith: result = strippedValue.StartsWith(strippedPropertyValue, StringComparison.OrdinalIgnoreCase); break; } } return(result); }
public override void WriteDebugLine(string message) { DebugStream.Add(message); }
protected override void OnCreate() { _debugStreamSys = World.GetExistingSystem <DebugStream>(); }