mirror of
https://gitee.com/csharpui/CPF.git
synced 2025-04-05 17:37:51 +08:00
37 lines
760 B
C#
37 lines
760 B
C#
using System;
|
|
|
|
namespace CPF.Mac.Foundation
|
|
{
|
|
[Register]
|
|
internal class InternalNSNotificationHandler : NSObject
|
|
{
|
|
private NSNotificationCenter notificationCenter;
|
|
|
|
private Action<NSNotification> notify;
|
|
|
|
public InternalNSNotificationHandler(NSNotificationCenter notificationCenter, Action<NSNotification> notify)
|
|
{
|
|
this.notificationCenter = notificationCenter;
|
|
this.notify = notify;
|
|
}
|
|
|
|
[Export("post:")]
|
|
[Preserve(Conditional = true)]
|
|
public void Post(NSNotification s)
|
|
{
|
|
notify(s);
|
|
s.Dispose();
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
if (disposing && notificationCenter != null)
|
|
{
|
|
notificationCenter.RemoveObserver(this);
|
|
notificationCenter = null;
|
|
}
|
|
base.Dispose(disposing);
|
|
}
|
|
}
|
|
}
|