public static MidiThruConnection[] Find(string persistentOwnerID, out MidiError error) { if (persistentOwnerID == null) { throw new ArgumentNullException(nameof(persistentOwnerID)); } IntPtr ret; using (var nssstr = new NSString(persistentOwnerID)) { error = MIDIThruConnectionFind(nssstr.Handle, out ret); } using (var data = Runtime.GetNSObject <NSData> (ret)) { var typeSize = Marshal.SizeOf(typeof(MidiThruConnectionRef)); var totalObjs = (int)data.Length / typeSize; if (totalObjs == 0) { return(null); } var basePtr = data.Bytes.ToInt32(); var connections = new MidiThruConnection[totalObjs]; for (int i = 0; i < totalObjs; i++) { connections[i] = new MidiThruConnection((uint)(basePtr + i * typeSize)); } return(connections); } }
public static MidiThruConnection[] Find(string persistentOwnerID, out MidiError error) { if (persistentOwnerID == null) throw new ArgumentNullException (nameof (persistentOwnerID)); IntPtr ret; using (var nssstr = new NSString (persistentOwnerID)) { error = MIDIThruConnectionFind (nssstr.Handle, out ret); } using (var data = Runtime.GetNSObject<NSData> (ret)) { var typeSize = Marshal.SizeOf (typeof (MidiThruConnectionRef)); var totalObjs = (int) data.Length / typeSize; if (totalObjs == 0) return null; var basePtr = data.Bytes.ToInt32 (); var connections = new MidiThruConnection[totalObjs]; for (int i = 0; i < totalObjs; i++) connections[i] = new MidiThruConnection ((uint)(basePtr + i * typeSize)); return connections; } }