/// <summary> /// Creates a GribMessage instance from a <seealso cref="Grib.Api.GribFile"/>. /// </summary> /// <param name="file">The file.</param> /// <param name="index">The index.</param> /// <returns></returns> public static GribMessage Create(GribFile file, int index) { GribMessage msg = null; int err = 0; // grib_api moves to the next message in a stream for each new handle GribHandle handle = GribApiProxy.GribHandleNewFromFile(file.Context, file, out err); if (err != 0) { throw GribApiException.Create(err); } if (handle != null) { msg = new GribMessage(handle, file.Context, index); } return(msg); }