private static long[] AsLongArray(JsValue value) { ArrayInstance jarr = value.AsArray(); long[] result = new long[jarr.GetLength()]; for (int i = 0; i < result.Length; i++) { result[i] = (long)jarr.GetProperty(i.ToString()).Value.AsNumber(); } return(result); }
public static byte[] ToByteArray(this ArrayInstance arrayInstance) { int length = (int)arrayInstance.GetLength(); byte[] result = new byte[length]; for (int i = 0; i < length; ++i) { result[i] = (byte)arrayInstance.Get(i.ToString()).AsNumber(); } return(result); }
/// <summary> /// Create an array whose elements are provided by the indexed properties of an array-like object. /// </summary> /// <param name="arrayLike"> The array-like object to convert. </param> /// <returns> An array. </returns> internal static object[] CreateListFromArrayLike(ObjectInstance arrayLike) { if (arrayLike is ArrayInstance arrayInstance) { return(arrayInstance.ToArray()); } uint length = ArrayInstance.GetLength(arrayLike); var result = new object[length]; for (uint i = 0; i < length; i++) { result[i] = arrayLike[i]; } return(result); }