本文整理汇总了C#中NSUrlConnection类的典型用法代码示例。如果您正苦于以下问题:C# NSUrlConnection类的具体用法?C# NSUrlConnection怎么用?C# NSUrlConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSUrlConnection类属于命名空间,在下文中一共展示了NSUrlConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReceivedData
// Collect all the data
public override void ReceivedData (NSUrlConnection connection, NSData data)
{
byte [] nb = new byte [result.Length + data.Length];
result.CopyTo (nb, 0);
Marshal.Copy (data.Bytes, nb, result.Length, (int) data.Length);
result = nb;
}
示例2: FinishedLoading
public override void FinishedLoading(NSUrlConnection connection)
{
cell.indicatorView.StopAnimating();
var downloadedImage = UIImage.LoadFromData(cell.imageData);
cell.imageData = null;
cell.ImageView.Image = downloadedImage;
}
示例3: FinishedLoading
public override void FinishedLoading (NSUrlConnection connection)
{
_view.indicatorView.StopAnimating();
UIImage downloadedImage = UIImage.LoadFromData(_view.imageData);
_view.imageData = null;
_view.Image = downloadedImage;
}
示例4: UploadStream
public void UploadStream (string url, long content_length, Action completed)
{
if (url == null)
throw new ArgumentNullException ("url");
AddHeader ("Expect", "100-continue");
AddHeader ("Content-Type", "application/octet-stream");
AddHeader ("Content-Length", content_length.ToString ());
InvokeOnMainThread (delegate {
try {
request = CreateNativePostRequest (url, content_length);
} catch (Exception e) {
Console.WriteLine ("Exception uploading stream");
Console.WriteLine (e);
completed ();
return;
}
url_connection = NSUrlConnection.FromRequest (request, new NativeUrlDelegate ((body) => {
completed ();
request.Dispose ();
}, (reason) => {
Console.WriteLine ("upload failed: " + reason);
completed ();
}));
});
}
示例5: ReceivedData
public override void ReceivedData (NSUrlConnection connection, NSData data)
{
if (_view.imageData==null)
_view.imageData = new NSMutableData();
_view.imageData.AppendData(data);
}
示例6: FinishedLoading
public override void FinishedLoading (NSUrlConnection connection)
{
BeginInvokeOnMainThread ( ()=> {
hud.CustomView = new UIImageView (UIImage.FromBundle ("37x-Checkmark.png"));
});
hud.Mode = MBProgressHUDMode.CustomView;
hud.Hide(true, 2);
}
示例7: DownloadUsingNSUrlRequest
void DownloadUsingNSUrlRequest (object sender, EventArgs e)
{
var downloadedDelegate = new CustomDelegate(this);
var req = new NSUrlRequest(new NSUrl("http://ch3cooh.hatenablog.jp/"));
NSUrlConnection connection = new NSUrlConnection(req, downloadedDelegate);
connection.Start();
}
示例8: ReceivedData
public override void ReceivedData(NSUrlConnection connection, NSData data)
{
if (this.tempData == null)
{
this.tempData = new NSMutableData();
}
this.tempData.AppendData(data);
}
示例9: StartLoading
public override void StartLoading()
{
if (this.Request == null)
{
return;
}
NSMutableUrlRequest mutableRequest = (NSMutableUrlRequest) this.Request.MutableCopy();
SetProperty(new NSString("YES"), "MsalCustomUrlProtocol", mutableRequest);
this.connection = new NSUrlConnection(mutableRequest, new MsalCustomConnectionDelegate(this), true);
}
开发者ID:AzureAD,项目名称:microsoft-authentication-library-for-dotnet,代码行数:11,代码来源:MsalCustomUrlProtocol.cs
示例10: FinishedLoading
public override void FinishedLoading(NSUrlConnection connection)
{
if (_statusCode != 200)
{
_failureCallback(string.Format("Did not receive a 200 HTTP status code, received '{0}'", _statusCode),
_statusCode);
return;
}
_successCallback(_data, _statusCode);
}
示例11: ReceivedResponse
public override void ReceivedResponse(NSUrlConnection connection, NSUrlResponse response)
{
var httpResponse = response as NSHttpUrlResponse;
Resp = httpResponse;
if (httpResponse == null)
{
_statusCode = -1;
return;
}
_statusCode = httpResponse.StatusCode;
}
示例12: FinishedDownloading
/// <summary>
/// Connection has successfully downloaded the asset to the destinationUrl file location.
/// You must copy/move this file to a more persisten/appropriate location
/// </summary>
public override void FinishedDownloading (NSUrlConnection connection, NSUrl destinationUrl)
{
Console.WriteLine ("-- Downloaded file: " + destinationUrl.Path);
Console.WriteLine ("---Target issue location: " + _issue.ContentUrl.Path);
var saveToFilename = System.IO.Path.Combine(_issue.ContentUrl.Path, "default.html");
if (!System.IO.File.Exists (saveToFilename))
System.IO.File.Move (destinationUrl.Path, saveToFilename);
Console.WriteLine ("---File moved for issue: " + _issue.Name);
//TODO: If you download a ZIP or something, process it in the background
//UIApplication.SharedApplication.BeginBackgroundTask ();
}
示例13: FinishedLoading
public override void FinishedLoading(NSUrlConnection connection)
{
var downloadedImage = UIImage.LoadFromData(this.tempData);
this.tempData = null;
this.InvokeOnMainThread(() =>
{
var imageView = this.tableView.CellAt(this.index).ViewWithTag(IncidentImageTag) as UIImageView;
// check if the row was deallocated when the user scrolled away. ignore.
if (imageView != null)
{
imageView.Image = downloadedImage;
}
});
}
示例14: FinishedDownloading
/// <summary>
/// Connection has successfully downloaded the asset to the destinationUrl file location.
/// You must copy/move this file to a more persisten/appropriate location
/// </summary>
public override void FinishedDownloading (NSUrlConnection connection, NSUrl destinationUrl)
{
Console.WriteLine ($"Downloaded file: {destinationUrl.Path}");
Console.WriteLine ($"Target issue location: {Issue.ContentUrl.Path}");
var saveToFilename = Path.Combine (Issue.ContentUrl.Path, "default.html");
if (!File.Exists (saveToFilename))
File.Move (destinationUrl.Path, saveToFilename);
Console.WriteLine ($"File moved for issue: {Issue.Name}");
if (OnDownloadingFinished != null)
OnDownloadingFinished ();
}
示例15: ReceivedData
public override void ReceivedData(NSUrlConnection connection, NSData data)
{
byte [] nb = new byte [result.Length + data.Length];
result.CopyTo(nb, 0);
Marshal.Copy(data.Bytes, nb, result.Length, (int) data.Length);
result = nb;
uint receivedLen = data.Length;
bytesReceived = (bytesReceived + receivedLen);
//if(expectedBytes != NSUrlResponse.) {
progress = ((bytesReceived/(float)expectedBytes)*100)/100;
percentComplete = progress*100;
Console.WriteLine(progress + " - " + percentComplete);
//}
}