2424//
2525using System . Collections . Generic ;
2626
27- // Disable until we get around to enable + fix any issues.
28- #nullable disable
27+ #nullable enable
2928
3029namespace Foundation {
3130
3231 [ Register ]
3332 internal class InternalNSNotificationHandler : NSObject {
34- NSNotificationCenter notificationCenter ;
33+ NSNotificationCenter ? notificationCenter ;
3534 Action < NSNotification > notify ;
3635
3736 public InternalNSNotificationHandler ( NSNotificationCenter notificationCenter , Action < NSNotification > notify )
@@ -64,24 +63,24 @@ public partial class NSNotificationCenter {
6463 const string postSelector = "post:" ;
6564
6665 class ObservedData {
67- public NSObject Observer ;
68- public string Name ;
69- public NSObject Object ;
66+ public NSObject ? Observer ;
67+ public string ? Name ;
68+ public NSObject ? Object ;
7069 }
7170
7271 List < ObservedData > __mt_ObserverList_var = new List < ObservedData > ( ) ;
7372
73+ /// <summary>
74+ /// Adds an observer for the specified notification.
75+ /// </summary>
7476 /// <param name="aName">The name of the notification to observe.</param>
75- /// <param name="notify">The delegate that will be invoked when the notification is posted.</param>
76- /// <param name="fromObject">If not-null, filters the notifications to those sent by this object.</param>
77- /// <summary>Adds an observer for the specified notification</summary>
78- /// <returns>An observer token that can be used later as the parameter passed to RemoveObserver (NSObject observer).</returns>
79- /// <remarks>
80- /// </remarks>
81- public NSObject AddObserver ( NSString aName , Action < NSNotification > notify , NSObject fromObject )
77+ /// <param name="notify">The delegate that will be invoked when the notification is posted.</param>
78+ /// <param name="fromObject">If not <see langword="null"/>, filters the notifications to those sent by this object.</param>
79+ /// <returns>An observer token that can be used later as the parameter passed to <see cref="RemoveObserver(NSObject)"/>.</returns>
80+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="notify"/> is <see langword="null"/>.</exception>
81+ public NSObject AddObserver ( NSString aName , Action < NSNotification > notify , NSObject ? fromObject )
8282 {
83- if ( notify is null )
84- throw new ArgumentNullException ( "notify" ) ;
83+ ArgumentNullException . ThrowIfNull ( notify ) ;
8584
8685 var proxy = new InternalNSNotificationHandler ( this , notify ) ;
8786
@@ -90,36 +89,39 @@ public NSObject AddObserver (NSString aName, Action<NSNotification> notify, NSOb
9089 return proxy ;
9190 }
9291
92+ /// <summary>
93+ /// Adds an observer for the specified notification.
94+ /// </summary>
9395 /// <param name="aName">The name of the notification to observe.</param>
94- /// <param name="notify">The delegate that will be invoked when the notification is posted.</param>
95- /// <summary>Adds an observer for the specified notification</summary>
96- /// <returns>An observer token that can be used later as the parameter passed to RemoveObserver (NSObject observer).</returns>
97- /// <remarks>
98- /// </remarks>
96+ /// <param name="notify">The delegate that will be invoked when the notification is posted.</param>
97+ /// <returns>An observer token that can be used later as the parameter passed to <see cref="RemoveObserver(NSObject)"/>.</returns>
98+ /// <exception cref="ArgumentNullException">Thrown when <paramref name="notify"/> is <see langword="null"/>.</exception>
9999 public NSObject AddObserver ( NSString aName , Action < NSNotification > notify )
100100 {
101101 return AddObserver ( aName , notify , null ) ;
102102 }
103103
104- /// <param name="keys">To be added.</param>
105- /// <summary>Removes multiple observers in one call.</summary>
106- /// <remarks>This removes all of the observers in the IEnumerable<NSObject> parameter.</remarks>
107- public void RemoveObservers ( IEnumerable < NSObject > keys )
104+ /// <summary>
105+ /// Removes multiple observers in one call.
106+ /// </summary>
107+ /// <param name="keys">The collection of observer tokens to remove.</param>
108+ /// <remarks>This removes all of the observers in the <see cref="IEnumerable{NSObject}"/> parameter.</remarks>
109+ public void RemoveObservers ( IEnumerable < NSObject > ? keys )
108110 {
109111 if ( keys is null )
110112 return ;
111113 foreach ( var k in keys )
112114 RemoveObserver ( k ) ;
113115 }
114116
115- void AddObserverToList ( NSObject observer , string aName , NSObject anObject )
117+ void AddObserverToList ( NSObject observer , string ? aName , NSObject ? anObject )
116118 {
117119 lock ( __mt_ObserverList_var )
118120 __mt_ObserverList_var . Add ( new ObservedData { Observer = observer , Name = aName , Object = anObject } ) ;
119121 MarkDirty ( ) ;
120122 }
121123
122- void RemoveObserversFromList ( NSObject observer , string aName , NSObject anObject )
124+ void RemoveObserversFromList ( NSObject observer , string ? aName , NSObject ? anObject )
123125 {
124126 lock ( __mt_ObserverList_var ) {
125127 for ( int i = __mt_ObserverList_var . Count - 1 ; i >= 0 ; i -- ) {
@@ -140,13 +142,20 @@ void RemoveObserversFromList (NSObject observer, string aName, NSObject anObject
140142 }
141143 }
142144
143- /// <summary>Provides data for an event based on a posted <see cref="NSNotification" /> object.</summary>
145+ /// <summary>
146+ /// Provides data for an event based on a posted <see cref="NSNotification"/> object.
147+ /// </summary>
144148 public class NSNotificationEventArgs : EventArgs {
145- /// <summary>The underlying <see cref="NSNotification" /> object from the posted notification.</summary>
149+ /// <summary>
150+ /// Gets the underlying <see cref="NSNotification"/> object from the posted notification.
151+ /// </summary>
152+ /// <value>The notification object.</value>
146153 public NSNotification Notification { get ; private set ; }
147154
148- /// <summary>Initializes a new instance of the <see cref="NSNotificationEventArgs" /> class.</summary>
149- /// <param name="notification">The underlying <see cref="NSNotification" /> object from the posted notification.</param>
155+ /// <summary>
156+ /// Initializes a new instance of the <see cref="NSNotificationEventArgs"/> class.
157+ /// </summary>
158+ /// <param name="notification">The underlying <see cref="NSNotification"/> object from the posted notification.</param>
150159 public NSNotificationEventArgs ( NSNotification notification )
151160 {
152161 Notification = notification ;
0 commit comments