50 lines
887 B
C#
50 lines
887 B
C#
using Foundation;
|
|
|
|
namespace Blahblah.Library.Network;
|
|
|
|
partial class NetworkTask
|
|
{
|
|
public NSMutableData? Data => data;
|
|
|
|
NSMutableData? data;
|
|
|
|
public NetworkTask(string url, CancellationToken token)
|
|
{
|
|
Url = url;
|
|
Token = token;
|
|
|
|
data = new NSMutableData();
|
|
}
|
|
|
|
public void SetCompleted(NSHttpUrlResponse? response)
|
|
{
|
|
OnCompleted(response);
|
|
Dispose();
|
|
}
|
|
|
|
public virtual bool OnResponsed(NSHttpUrlResponse response)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public virtual void OnReceived(int length)
|
|
{
|
|
}
|
|
|
|
protected abstract void OnCompleted(NSHttpUrlResponse? response);
|
|
|
|
private partial void DisposingInternal()
|
|
{
|
|
Disposing();
|
|
if (data != null)
|
|
{
|
|
data.Dispose();
|
|
data = null;
|
|
}
|
|
}
|
|
|
|
protected virtual void Disposing()
|
|
{
|
|
}
|
|
}
|