Ejemplo n.º 1
0
        public void IsArrayOfType()
        {
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[], object>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, ], object>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, , ], object>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, , , ], object>());

            Assert.IsFalse(ArrayIdentification.IsArrayOfType <object[], int>());
            Assert.IsFalse(ArrayIdentification.IsArrayOfType <object[], short>());
            Assert.IsFalse(ArrayIdentification.IsArrayOfType <short[], int>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <int[], int>());

            Assert.IsTrue(ArrayIdentification.IsArrayOfByte <byte[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfInt16 <short[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfInt32 <int[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfInt64 <long[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfSByte <sbyte[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfUInt16 <ushort[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfUInt32 <uint[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfUInt64 <ulong[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfSingle <float[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfDouble <double[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfDecimal <decimal[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfChar <char[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfBoolean <bool[]>());
            Assert.IsTrue(ArrayIdentification.IsArrayOfString <string[]>());
        }
Ejemplo n.º 2
0
        public void IsJaggedArrayOfType()
        {
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[][], object>(2));
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, ][], object>(2));
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, ][, ], object>(2));
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, ][, , , ], object>(2));

            Assert.IsFalse(ArrayIdentification.IsArrayOfType <object[][][], object>(2));
            Assert.IsFalse(ArrayIdentification.IsArrayOfType <object[][][][], object>(2));
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[][][][], object>(4));
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[][][][][], object>(6));
            Assert.IsTrue(ArrayIdentification.IsArrayOfType <object[, , , ][, ][, , , ][, , , , , , ][, , ], object>(6));
        }
Ejemplo n.º 3
0
 public static bool IsArrayOfChar(this Array array) => ArrayIdentification.IsArrayOfType <char>(array.GetType());
Ejemplo n.º 4
0
 public static bool IsArrayOfDecimal(this Array array) => ArrayIdentification.IsArrayOfType <decimal>(array.GetType());
Ejemplo n.º 5
0
 public static bool IsArrayOfDouble(this Array array) => ArrayIdentification.IsArrayOfType <double>(array.GetType());
Ejemplo n.º 6
0
 public static bool IsArrayOfSingle(this Array array) => ArrayIdentification.IsArrayOfType <float>(array.GetType());
Ejemplo n.º 7
0
 public static bool IsArrayOfUInt64(this Array array) => ArrayIdentification.IsArrayOfType <ulong>(array.GetType());
Ejemplo n.º 8
0
 /// <summary>Determines whether an array type contains elements of the provided type. It only checks for multidimensional arrays (of the form [(,)*]). Jagged arrays are not taken into consideration in this implementation. Also built as an extension method to allow per-instance call.</summary>
 /// <typeparam name="TElement">The type of the element the array stores.</typeparam>
 /// <param name="array">The array whose type to examine.</param>
 /// <returns>Whether the given array type stores elements of the <typeparamref name="TElement"/> type.</returns>
 public static bool IsArrayOfType <TElement>(this Array array) => ArrayIdentification.IsArrayOfType <TElement>(array.GetType());
Ejemplo n.º 9
0
 public static bool IsArrayOfInt16(this Array array) => ArrayIdentification.IsArrayOfType <short>(array.GetType());
Ejemplo n.º 10
0
 //[Benchmark]
 public void Array30D() => ArrayIdentification.IsArrayOfType <object[, , , , , , , , , , , , , , , , , , , , , , , , , , , , , ], object>();
Ejemplo n.º 11
0
 //[Arguments(6)]
 //[Arguments(10)]
 //[Arguments(25)]
 //[Arguments(32)]
 public void JaggedArray32x32x32x32x32D(int maxJaggingLevel)
 {
     ArrayIdentification.IsArrayOfType <object[, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ][, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ][, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ][, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ][, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ], object>(maxJaggingLevel);
 }
Ejemplo n.º 12
0
 //[Benchmark]
 public void JaggedArray6x5x4x3x2x1D() => ArrayIdentification.IsArrayOfType <object[, , , , , ][, , , , ][, , , ][, , ][, ][], object>(6);
Ejemplo n.º 13
0
 //[Benchmark]
 public void JaggedArray1x2x3x4x5x6D() => ArrayIdentification.IsArrayOfType <object[][, ][, , ][, , , ][, , , , ][, , , , , ], object>(6);
Ejemplo n.º 14
0
 //[Benchmark]
 public void JaggedArray1x1x1x1x1x1D() => ArrayIdentification.IsArrayOfType <object[][][][][][], object>(6);
Ejemplo n.º 15
0
 public static bool IsArrayOfBoolean(this Array array) => ArrayIdentification.IsArrayOfType <bool>(array.GetType());
Ejemplo n.º 16
0
 public static bool IsArrayOfString(this Array array) => ArrayIdentification.IsArrayOfType <string>(array.GetType());
Ejemplo n.º 17
0
 public static bool IsArrayOfSByte(this Array array) => ArrayIdentification.IsArrayOfType <sbyte>(array.GetType());
Ejemplo n.º 18
0
 /// <summary>Determines whether an array type contains elements of the provided type. It also checks for jagged arrays up to a maximum jagging level. Also built as an extension method to allow per-instance call.</summary>
 /// <typeparam name="TElement">The type of the element the array stores.</typeparam>
 /// <param name="array">The array whose type to examine.</param>
 /// <param name="maxJaggingLevel">The maximum jagging level of the array (1 means up to [], 2 means up to [][], etc.).</param>
 /// <returns>Whether the given array type stores elements of the <typeparamref name="TElement"/> type.</returns>
 public static bool IsArrayOfType <TElement>(this Array array, int maxJaggingLevel) => ArrayIdentification.IsArrayOfType <TElement>(array.GetType(), maxJaggingLevel);
Ejemplo n.º 19
0
 public static bool IsArrayOfUInt32(this Array array) => ArrayIdentification.IsArrayOfType <uint>(array.GetType());