public static string Generate(int length) { Guard.MinimumAndNotNull(nameof(length), length, 1); return(new string(Enumerable.Repeat(Constants.Chars, length) .Select(s => s[Random.Next(s.Length)]).ToArray())); }
public static string Generate(int length) { Guard.MinimumAndNotNull(nameof(length), length, 1); const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; return(new string(Enumerable.Repeat(chars, length) .Select(s => s[Random.Next(s.Length)]).ToArray())); }
public EventsAwaiter(Action<EventHandler<TEventArgs>> subscribe, Action<EventHandler<TEventArgs>> unsubscribe, int count) { Guard.MinimumAndNotNull(nameof(count), count, 0); Lock = new object(); var eventsArrived = new List<TaskCompletionSource<TEventArgs>>(count); for (int i = 0; i < count; i++) { eventsArrived.Add(new TaskCompletionSource<TEventArgs>()); } EventsArrived = eventsArrived; subscribe(Subscription); Unsubscribe = unsubscribe; }