本文整理汇总了C#中NSUrlConnection类的典型用法代码示例。如果您正苦于以下问题:C# NSUrlConnection类的具体用法?C# NSUrlConnection怎么用?C# NSUrlConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSUrlConnection类属于命名空间,在下文中一共展示了NSUrlConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:GSerjo,项目名称:monotouch-samples,代码行数:8,代码来源:Cocoa.cs
示例2: FinishedLoading
public override void FinishedLoading(NSUrlConnection connection)
{
cell.indicatorView.StopAnimating();
var downloadedImage = UIImage.LoadFromData(cell.imageData);
cell.imageData = null;
cell.ImageView.Image = downloadedImage;
}
开发者ID:NotMyself,项目名称:FurnishlyApp,代码行数:7,代码来源:ProductTableViewCell.cs
示例3: FinishedLoading
public override void FinishedLoading (NSUrlConnection connection)
{
_view.indicatorView.StopAnimating();
UIImage downloadedImage = UIImage.LoadFromData(_view.imageData);
_view.imageData = null;
_view.Image = downloadedImage;
}
开发者ID:ursushoribilis,项目名称:monotouch-controls,代码行数:7,代码来源:UIWebImageView.cs
示例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 ();
}));
});
}
开发者ID:robertgreen,项目名称:monotouch-samples,代码行数:28,代码来源:NativeUploader.cs
示例5: ReceivedData
public override void ReceivedData (NSUrlConnection connection, NSData data)
{
if (_view.imageData==null)
_view.imageData = new NSMutableData();
_view.imageData.AppendData(data);
}
开发者ID:21Off,项目名称:21Off,代码行数:7,代码来源:UIWebImageView.cs
示例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);
}
开发者ID:MobileFit,项目名称:CoachV2,代码行数:8,代码来源:MyNSUrlConnectionDelegete.cs
示例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();
}
开发者ID:CH3COOH,项目名称:Softbuild.XamarinIOSSamples,代码行数:8,代码来源:WebRequestSampleViewController.cs
示例8: ReceivedData
public override void ReceivedData(NSUrlConnection connection, NSData data)
{
if (this.tempData == null)
{
this.tempData = new NSMutableData();
}
this.tempData.AppendData(data);
}
开发者ID:kirpasingh,项目名称:MicrosoftAzureTrainingKit,代码行数:9,代码来源:ImageConnectionDelegate.cs
示例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);
}
开发者ID:elsewhat,项目名称:AltinnApp,代码行数:11,代码来源:NativeUrlDelegate.cs
示例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;
}
开发者ID:elsewhat,项目名称:AltinnApp,代码行数:12,代码来源:NativeUrlDelegate.cs
示例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 ();
}
开发者ID:g7steve,项目名称:monotouch-samples,代码行数:18,代码来源:NewsstandUrlDelegate.cs
示例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;
}
});
}
开发者ID:kirpasingh,项目名称:MicrosoftAzureTrainingKit,代码行数:15,代码来源:ImageConnectionDelegate.cs
示例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 ();
}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:19,代码来源:NewsstandUrlDelegate.cs
示例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);
//}
}
开发者ID:ytn3rd,项目名称:random-code-things,代码行数:17,代码来源:ProxyTest_NSUrlConnectionDelegate.cs
示例16: Selected
public override void Selected(DialogViewController dvc, UITableView tableView, NSIndexPath path)
{
tableView.DeselectRow(path, false);
if (loading)
return;
var cell = GetActiveCell();
var spinner = StartSpinner(cell);
loading = true;
var request = new NSUrlRequest(new NSUrl(apiNode.ApiUrl), NSUrlRequestCachePolicy.UseProtocolCachePolicy, 60);
var connection = new NSUrlConnection(request, new ConnectionDelegate((data, error) =>
{
var apiNodes = DrupalApiParser.ParseJsonStream(data);
loading = false;
spinner.StopAnimating();
spinner.RemoveFromSuperview();
string childType = apiNode["childType"];
if (this.Count == 0)
Add(new Section(""));
else
this[0].Clear();
foreach (var element in apiNodes)
{
this[0].Add(CreateElement(element, apiNode));
}
var newDvc = new DialogViewController(this, true)
{
Autorotate = true
};
PrepareDialogViewController(newDvc);
dvc.ActivateController(newDvc);
return;
}));
}
开发者ID:josiahpeters,项目名称:CCBoise,代码行数:41,代码来源:CustomRootElement.cs
示例17: ReceivedData
public override void ReceivedData(NSUrlConnection connection, NSData d)
{
data.AppendData (d);
}
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:4,代码来源:Comms.cs
示例18: ReceivedAuthenticationChallenge
public override void ReceivedAuthenticationChallenge(NSUrlConnection connection, NSUrlAuthenticationChallenge challenge)
{
// if (challenge.PreviousFailureCount > 0) {
// showError = false;
// challenge.Sender.CancelAuthenticationChallenge (challenge);
// Application.AuthenticationFailure ();
// return;
// }
//
// if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodServerTrust")
// challenge.Sender.UseCredentials (NSUrlCredential.FromTrust (challenge.ProtectionSpace.ServerTrust), challenge);
//
// if (challenge.ProtectionSpace.AuthenticationMethod == "NSURLAuthenticationMethodDefault" &&
// Application.Account != null && Application.Account.Login != null && Application.Account.Password != null) {
// challenge.Sender.UseCredentials (NSUrlCredential.FromUserPasswordPersistance (
// Application.Account.Login, Application.Account.Password, NSUrlCredentialPersistence.None), challenge);
// }
}
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:19,代码来源:Comms.cs
示例19: FinishedLoading
public override void FinishedLoading(NSUrlConnection connection)
{
Comms.ConnectionEnded (_name);
callback (data.ToString ());
}
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:5,代码来源:Comms.cs
示例20: FailedWithError
public override void FailedWithError(NSUrlConnection connection, NSError error)
{
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
if (showError)
//Application.ShowNetworkError (error.LocalizedDescription);
new UIAlertView("Network Error", "Communications problem", null, "Close").Show();
if (_failure != null)
_failure ();
}
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:10,代码来源:Comms.cs
注:本文中的NSUrlConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论