合并主线最近几年来的主要更新,重点推进TinyHttpClient,替代HttpClient
大石头 authored at 2023-03-08 18:39:12
1.02 KiB
X_NET20
using System.Threading;

namespace System
{
	public static class ArrayExtensions
	{
		public static TTarget[] ConvertAll<TSrc, TTarget>(this TSrc[] src, Func<TSrc, TTarget> converter)
		{
			if (src == null || converter == null)
			{
				return null;
			}
			TTarget[] localArray = new TTarget[src.Length];
			for (int i = 0; i < localArray.Length; i++)
			{
				localArray[i] = converter(src[i]);
			}
			return localArray;
		}

		public static void CheckArray(this WaitHandle handle, WaitHandle[] handles, bool waitAll)
		{
			if (handles == null)
			{
				throw new ArgumentNullException("waitHandles");
			}
			int length = handles.Length;
			if (length > 64)
			{
				throw new NotSupportedException("Too many handles");
			}
			if (handles.Length == 0)
			{
				if (waitAll)
				{
					throw new ArgumentNullException("waitHandles");
				}
				throw new ArgumentException();
			}
			foreach (WaitHandle w in handles)
			{
				if (w == null)
				{
					throw new ArgumentNullException("waitHandles", "null handle");
				}
			}
		}
	}
}