Пример #1
0
        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()));
        }
Пример #2
0
        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()));
        }
Пример #3
0
		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;
		}