public MidiError SetParams(MidiThruConnectionParams connectionParams)
        {
            if (Handle == InvalidRef)
            {
                throw new ObjectDisposedException("MidiThruConnection");
            }
            if (connectionParams is null)
            {
                throw new ArgumentNullException(nameof(connectionParams));
            }

            using (var data = connectionParams.WriteStruct()) {
                var error = MIDIThruConnectionSetParams(Handle, data.Handle);
                return(error);
            }
        }
        public static MidiThruConnection Create(string persistentOwnerID, MidiThruConnectionParams connectionParams, out MidiError error)
        {
            MidiThruConnectionRef ret;

            using (var data = connectionParams.WriteStruct()) {
                var retStr = NSString.CreateNative(persistentOwnerID);
                error = MIDIThruConnectionCreate(retStr, data.Handle, out ret);
                NSString.ReleaseNative(retStr);
            }

            if (error != MidiError.Ok)
            {
                return(null);
            }

            return(new MidiThruConnection(ret));
        }