| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using System.Text; |
| | 5 | | using System.Threading.Tasks; |
| | 6 | |
|
| | 7 | | namespace MorphoGeometry |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Extension class. |
| | 11 | | /// </summary> |
| | 12 | | internal static class Extension |
| | 13 | | { |
| | 14 | | /// <summary> |
| | 15 | | /// Deconstruct an array with 1 item. |
| | 16 | | /// </summary> |
| | 17 | | /// <typeparam name="T">Type.</typeparam> |
| | 18 | | /// <param name="items">Array to deconstruct.</param> |
| | 19 | | /// <param name="t0">Item.</param> |
| | 20 | | public static void Deconstruct<T>(this T[] items, out T t0) |
| 0 | 21 | | { |
| 0 | 22 | | t0 = items.Length > 0 ? items[0] : default(T); |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Deconstruct an array with 2 item. |
| | 27 | | /// </summary> |
| | 28 | | /// <typeparam name="T">Type.</typeparam> |
| | 29 | | /// <param name="items">Array to deconstruct.</param> |
| | 30 | | /// <param name="t0">First item.</param> |
| | 31 | | /// <param name="t1">Second item.</param> |
| | 32 | | public static void Deconstruct<T>(this T[] items, out T t0, |
| | 33 | | out T t1) |
| 0 | 34 | | { |
| 0 | 35 | | t0 = items.Length > 0 ? items[0] : default(T); |
| 0 | 36 | | t1 = items.Length > 1 ? items[1] : default(T); |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Deconstruct an array with 3 item. |
| | 41 | | /// </summary> |
| | 42 | | /// <typeparam name="T">Type.</typeparam> |
| | 43 | | /// <param name="items">Array to deconstruct.</param> |
| | 44 | | /// <param name="t0">First item.</param> |
| | 45 | | /// <param name="t1">Second item.</param> |
| | 46 | | /// <param name="t2">Third item.</param> |
| | 47 | | public static void Deconstruct<T>(this T[] items, out T t0, |
| | 48 | | out T t1, out T t2) |
| 0 | 49 | | { |
| 0 | 50 | | t0 = items.Length > 0 ? items[0] : default(T); |
| 0 | 51 | | t1 = items.Length > 1 ? items[1] : default(T); |
| 0 | 52 | | t2 = items.Length > 2 ? items[2] : default(T); |
| 0 | 53 | | } |
| | 54 | | } |
| | 55 | | } |