Use INativeObject.GetHandle in a few places to simplify code.

Since INativeObject.GetHandle is an extension method that can detect a null
'this' value and returns IntPtr.Zero.
This commit is contained in:
Rolf Bjarne Kvinge 2018-08-01 02:47:47 +02:00
Родитель a6efd56402
Коммит 06e4426e1c
5 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -387,7 +387,7 @@ namespace Network {
unsafe void LowLevelSend (IntPtr handle, DispatchData buffer, IntPtr contentContext, bool isComplete, void *callback) unsafe void LowLevelSend (IntPtr handle, DispatchData buffer, IntPtr contentContext, bool isComplete, void *callback)
{ {
nw_connection_send (handle: GetCheckedHandle (), nw_connection_send (handle: GetCheckedHandle (),
dispatchData: buffer == null ? IntPtr.Zero : buffer.Handle, dispatchData: buffer.GetHandle (),
contentContext: contentContext, contentContext: contentContext,
isComplete: isComplete, isComplete: isComplete,
callback: callback); callback: callback);

Просмотреть файл

@ -121,7 +121,7 @@ namespace Network {
return new NWContentContext (h, owns: true); return new NWContentContext (h, owns: true);
} }
set { set {
nw_content_context_set_antecedent (GetCheckedHandle (), value == null ? IntPtr.Zero : value.Handle); nw_content_context_set_antecedent (GetCheckedHandle (), value.GetHandle ());
} }
} }

Просмотреть файл

@ -214,7 +214,7 @@ namespace Network {
public void SetAdvertiseDescriptor (NWAdvertiseDescriptor descriptor) public void SetAdvertiseDescriptor (NWAdvertiseDescriptor descriptor)
{ {
nw_listener_set_advertise_descriptor (GetCheckedHandle (), descriptor == null ? IntPtr.Zero : descriptor.handle); nw_listener_set_advertise_descriptor (GetCheckedHandle (), descriptor.GetHandle ());
} }
} }
} }

Просмотреть файл

@ -271,7 +271,7 @@ namespace Network {
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
public void RequireInterface (NWInterface iface) public void RequireInterface (NWInterface iface)
{ {
nw_parameters_require_interface (GetCheckedHandle (), iface == null ? IntPtr.Zero : iface.handle); nw_parameters_require_interface (GetCheckedHandle (), iface.GetHandle ());
} }
[TV (12,0), Mac (10,14), iOS (12,0)] [TV (12,0), Mac (10,14), iOS (12,0)]
@ -491,7 +491,7 @@ namespace Network {
} }
set { set {
nw_parameters_set_local_endpoint (GetCheckedHandle (), value == null ? IntPtr.Zero : value.handle); nw_parameters_set_local_endpoint (GetCheckedHandle (), value.GetHandle ());
} }
} }
} }

Просмотреть файл

@ -87,7 +87,7 @@ namespace Network {
[TV (12, 0), Mac (10, 14), iOS (12, 0)] [TV (12, 0), Mac (10, 14), iOS (12, 0)]
public NWProtocolOptions TransportProtocol { public NWProtocolOptions TransportProtocol {
get => new NWProtocolOptions (nw_protocol_stack_copy_transport_protocol (GetCheckedHandle ()), owns: true); get => new NWProtocolOptions (nw_protocol_stack_copy_transport_protocol (GetCheckedHandle ()), owns: true);
set => nw_protocol_stack_set_transport_protocol (GetCheckedHandle (), value.Handle); set => nw_protocol_stack_set_transport_protocol (GetCheckedHandle (), value.GetHandle ());
} }
[TV (12, 0), Mac (10, 14), iOS (12, 0)] [TV (12, 0), Mac (10, 14), iOS (12, 0)]