static void Run() { var a = new string('a', 10000); var b = new string('b', 1000000); ZString.Join(',', new string[] { a, b }); }
public void JoinOverloads3() { ZString.Join(',', new string[] { }.ToList()).Should().Be(string.Join(',', new string[0])); ZString.Join(',', new[] { 1 }.ToList()).Should().Be(string.Join(',', new[] { 1 })); ZString.Join(',', new[] { 1, 2 }.ToList()).Should().Be(string.Join(',', new[] { 1, 2 })); ZString.Join(',', new[] { 1, 2, 3 }.ToList()).Should().Be(string.Join(',', new[] { 1, 2, 3 })); ZString.Join(',', (IList <int>) new int[] { }).Should().Be(string.Join(',', new string[0])); ZString.Join(',', (IList <int>) new[] { 1 }).Should().Be(string.Join(',', new[] { 1 })); ZString.Join(',', (IList <int>) new[] { 1, 2 }).Should().Be(string.Join(',', new[] { 1, 2 })); ZString.Join(',', (IList <int>) new[] { 1, 2, 3 }).Should().Be(string.Join(',', new[] { 1, 2, 3 })); ZString.Join(',', (IReadOnlyList <int>) new int[] { }).Should().Be(string.Join(',', new string[0])); ZString.Join(',', (IReadOnlyList <int>) new[] { 1 }).Should().Be(string.Join(',', new[] { 1 })); ZString.Join(',', (IReadOnlyList <int>) new[] { 1, 2 }).Should().Be(string.Join(',', new[] { 1, 2 })); ZString.Join(',', (IReadOnlyList <int>) new[] { 1, 2, 3 }).Should().Be(string.Join(',', new[] { 1, 2, 3 })); ZString.Join(',', (ICollection <int>) new int[] { }).Should().Be(string.Join(',', new string[0])); ZString.Join(',', (ICollection <int>) new[] { 1 }).Should().Be(string.Join(',', new[] { 1 })); ZString.Join(',', (ICollection <int>) new[] { 1, 2 }).Should().Be(string.Join(',', new[] { 1, 2 })); ZString.Join(',', (ICollection <int>) new[] { 1, 2, 3 }).Should().Be(string.Join(',', new[] { 1, 2, 3 })); ZString.Join(',', (IReadOnlyCollection <int>) new int[] { }).Should().Be(string.Join(',', new string[0])); ZString.Join(',', (IReadOnlyCollection <int>) new[] { 1 }).Should().Be(string.Join(',', new[] { 1 })); ZString.Join(',', (IReadOnlyCollection <int>) new[] { 1, 2 }).Should().Be(string.Join(',', new[] { 1, 2 })); ZString.Join(',', (IReadOnlyCollection <int>) new[] { 1, 2, 3 }).Should().Be(string.Join(',', new[] { 1, 2, 3 })); }
internal HeaderWriter(IEnumerable <string> timingAllowOrigins) { var origins = timingAllowOrigins?.ToArray(); if (origins?.Length > 0) { _timingAllowOriginValue = ZString.Join(",", origins); } }
public void ConcatHugeString() { var a = new string('a', 10000); var b = new string('b', 1000000); var actrual = ZString.Join(',', new string[] { a, b }); var expected = string.Join(',', new string[] { a, b }); actrual.Should().Be(expected); }
private void Application_Startup(object sender, StartupEventArgs e) { var args = e.Args; var wins = new List <Window>(); if (args.Length > 0) { if (args[0].StartsWith("/S", StringComparison.InvariantCultureIgnoreCase)) { wins.AddRange(ScreenSaver()); } else if (args[0].StartsWith("/C", StringComparison.InvariantCultureIgnoreCase)) { wins.Add(new SettingsWindow()); } else if (args[0].StartsWith("/P", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length < 2) { var ex = new ArgumentException(ZString.Join(" ", args)); _ = MessageBox.Show(ex.Message, ex.ParamName, MessageBoxButton.OK, MessageBoxImage.Error); throw ex; } //var previewWndHandle = new IntPtr(long.Parse(args[1], CultureInfo.InvariantCulture)); //wins.Add(new ScreenSaverWindow(previewWndHandle)); } else { var ex = new ArgumentException(ZString.Join(" ", args)); _ = MessageBox.Show(ex.Message, ex.ParamName, MessageBoxButton.OK, MessageBoxImage.Error); throw ex; } } else { wins.Add(new SettingsWindow()); } foreach (var win in wins) { win.Show(); } }
public void JoinStrings() { var values = new[] { "abc", null, "def" }; { const char sep = ','; var expected = string.Join(sep, values); ZString.Join(sep, new ReadOnlySpan <string>(values)).Should().Be(expected); ZString.Join(sep, values).Should().Be(expected); ZString.Join(sep, values.ToList()).Should().Be(expected); ZString.Join(sep, values.AsEnumerable()).Should().Be(expected); } { const string sep = "_,_"; var expected = string.Join(sep, values); ZString.Join(sep, new ReadOnlySpan <string>(values)).Should().Be(expected); ZString.Join(sep, values).Should().Be(expected); ZString.Join(sep, values.ToList()).Should().Be(expected); ZString.Join(sep, values.AsEnumerable()).Should().Be(expected); } }
public void JoinOverloads() { ZString.Join("_,_", new string[0]).Should().Be(string.Join("_,_", new string[0])); ZString.Join("_,_", new[] { 1 }).Should().Be(string.Join("_,_", new[] { 1 })); ZString.Join("_,_", new[] { 1, 2 }).Should().Be(string.Join("_,_", new[] { 1, 2 })); ZString.Join("_,_", new[] { 1, 2, 3 }).Should().Be(string.Join("_,_", new[] { 1, 2, 3 })); ZString.Join("_,_", new string[] { }.AsEnumerable()).Should().Be(string.Join("_,_", new string[0])); ZString.Join("_,_", new[] { 1 }.AsEnumerable()).Should().Be(string.Join("_,_", new[] { 1 })); ZString.Join("_,_", new[] { 1, 2 }.AsEnumerable()).Should().Be(string.Join("_,_", new[] { 1, 2 })); ZString.Join("_,_", new[] { 1, 2, 3 }.AsEnumerable()).Should().Be(string.Join("_,_", new[] { 1, 2, 3 })); ZString.Join(',', new string[0]).Should().Be(string.Join(",", new string[0])); ZString.Join(',', new[] { 1 }).Should().Be(string.Join(",", new[] { 1 })); ZString.Join(',', new[] { 1, 2 }).Should().Be(string.Join(",", new[] { 1, 2 })); ZString.Join(',', new[] { 1, 2, 3 }).Should().Be(string.Join(",", new[] { 1, 2, 3 })); ZString.Join(',', new string[0].AsEnumerable()).Should().Be(string.Join(",", new string[0])); ZString.Join(',', new[] { 1 }.AsEnumerable()).Should().Be(string.Join(",", new[] { 1 })); ZString.Join(',', new[] { 1, 2 }.AsEnumerable()).Should().Be(string.Join(",", new[] { 1, 2 })); ZString.Join(',', new[] { 1, 2, 3 }.AsEnumerable()).Should().Be(string.Join(",", new[] { 1, 2, 3 })); }
/// <summary> /// Provides validation for the keyword. /// </summary> /// <param name="context">Contextual details for the validation process.</param> public void Validate(ValidationContext context) { if (context.LocalInstance.ValueKind != JsonValueKind.Array) { context.IsValid = true; return; } if (!Value) { context.IsValid = true; return; } var count = context.LocalInstance.GetArrayLength(); var duplicates = new List <(int, int)>(); for (int i = 0; i < count - 1; i++) { for (int j = i + 1; j < count; j++) { if (context.LocalInstance[i].IsEquivalentTo(context.LocalInstance[j])) { duplicates.Add((i, j)); } } } context.IsValid = !duplicates.Any(); if (!context.IsValid) { context.IsValid = false; var pairs = ZString.Join(", ", duplicates.Select(d => $"({d.Item1}, {d.Item2})")); context.Message = $"Found duplicates at the following index pairs: {pairs}"; } }
public string ZJoinEnumerable10() => ZString.Join(Separator, _enum10);
public string ZJoinArray10() => ZString.Join(Separator, _array10);
public string ZJoinList10() => ZString.Join(Separator, _list10);
public string ZJoinEnumerable2() => ZString.Join(Separator, _enum2);
public string ZJoinList2() => ZString.Join(Separator, _list2);
public string ZJoinEmptyList() => ZString.Join(Separator, _emptyList);