コード例 #1
0
		private static bool GetArray<ARG3, ARG2, T>(
			int arg1, ARG2 arg2, ARG3 arg3,
			GetArray1ArgDel<T> func1,
			GetArray2ArgDel<ARG2, T> func2,
			GetArray3ArgDel<ARG3, ARG2, T> func3,
			[Out] T[] data, int start, int count, int tupleSize)
		{
			int maxArraySize = HEU_Defines.HAPI_MAX_PAGE_SIZE / (Marshal.SizeOf(typeof(T)) * tupleSize);
			int localCount = count;
			int currentIndex = start;

			bool bResult = true;
			while (localCount > 0)
			{
				int length = 0;
				if (localCount > maxArraySize)
				{
					length = maxArraySize;
					localCount -= maxArraySize;
				}
				else
				{
					length = localCount;
					localCount = 0;
				}

				T[] localArray = new T[length * tupleSize];

				if (func1 != null)
				{
					bResult = func1(arg1, localArray, currentIndex, length);
				}
				else if (func2 != null)
				{
					bResult = func2(arg1, arg2, localArray, currentIndex, length);
				}
				else if (func3 != null)
				{
					bResult = func3(arg1, arg2, arg3, localArray, currentIndex, length);
				}
				else
				{
					HEU_HAPIUtility.LogError("No valid delegates given to GetArray< T >!");
					return false;
				}

				if (!bResult)
				{
					break;
				}

				// Copy from temporary array
				for (int i = currentIndex; i < (currentIndex + length); ++i)
				{
					for (int j = 0; j < tupleSize; ++j)
					{
						data[i * tupleSize + j] = localArray[(i - currentIndex) * tupleSize + j];
					}
				}

				currentIndex += length;
			}

			return bResult;
		}
コード例 #2
0
		public static bool GetArray3Arg<ARG3, ARG2, T>(int arg1, ARG2 arg2, ARG3 arg3, GetArray3ArgDel<ARG3, ARG2, T> func, [Out] T[] data, int start, int count)
		{
			return GetArray(arg1, arg2, arg3, null, null, func, data, start, count, 1);
		}