private string Join(ICollection <object> collection) { var joiner = new StringJoiner(","); foreach (var value in collection) { joiner.Add(value.ToString()); } return(joiner.ToString()); }
public static string SortGetExpectedPoints( BoundingBox bb, IList<SupportSpatialPoint> points) { var joiner = new StringJoiner(","); foreach (var point in points) { if (bb.ContainsPoint(point.Px.Value, point.Py.Value)) { joiner.Add(point.Id); } } return joiner.ToString(); }
private static void AssertCompare( MXCIFQuadTree tree, String expected, IDictionary <int, String> received) { StringJoiner joiner = new StringJoiner(","); foreach (string value in received.Values) { joiner.Add(value); } Assert.AreEqual(expected, joiner.ToString()); Assert.IsTrue((expected.Length == 0 ? 0 : expected.SplitCsv().Length) <= MXCIFQuadTreeFilterIndexCount.Count(tree)); }
/** * Makes the warning for when the registry responds with an image digest that is not the expected * digest of the image. * * @param expectedDigest the expected image digest * @param receivedDigests the received image digests * @return the warning message */ private static string MakeUnexpectedImageDigestWarning( DescriptorDigest expectedDigest, IList <string> receivedDigests) { if (receivedDigests.Count == 0) { return("Expected image digest " + expectedDigest + ", but received none"); } StringJoiner message = new StringJoiner(", ", "Expected image digest " + expectedDigest + ", but received: ", ""); foreach (string receivedDigest in receivedDigests) { message.Add(receivedDigest); } return(message.ToString()); }
public static string SortGetExpectedRectangles( BoundingBox bb, IList<SupportSpatialEventRectangle> rectangles) { var joiner = new StringJoiner(","); foreach (var rect in rectangles) { if (bb.IntersectsBoxIncludingEnd( rect.X.Value, rect.Y.Value, rect.Width.Value, rect.Height.Value)) { joiner.Add(rect.Id); } } return joiner.ToString(); }
public static string ToDelimitedString(this IEnumerable source, string delimiter = ",", string quote = "\"", Func <object, string> convertToString = null) { if (convertToString == null) { convertToString = x => (x == null ? "" : x.ToString()); } var data = ( from object a in source let s = convertToString(a) select s.Contains(delimiter) || s.Contains("\r") || s.Contains("\n") || s.Contains(quote) ? String.Format("{0}{1}{0}", quote, s) : s ); StringJoiner sj = new StringJoiner(delimiter); data.ForEach(e => sj.Add(e)); return(sj.ToString()); }
public static string SortJoinProperty( EventBean[] events, string propertyName) { var sorted = new SortedDictionary<int, string>(); if (events != null) { foreach (var @event in events) { var value = @event.Get(propertyName).ToString(); var num = int.Parse(value.Substring(1)); sorted.Put(num, value); } } var joiner = new StringJoiner(","); foreach (var data in sorted.Values) { joiner.Add(data); } return joiner.ToString(); }