当前位置: 首页>>代码示例>>C#>>正文


C# NSUrlRequest类代码示例

本文整理汇总了C#中NSUrlRequest的典型用法代码示例。如果您正苦于以下问题:C# NSUrlRequest类的具体用法?C# NSUrlRequest怎么用?C# NSUrlRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NSUrlRequest类属于命名空间,在下文中一共展示了NSUrlRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NSUrlConnectionWrapper

		public NSUrlConnectionWrapper(NSUrlRequest request, EscozUrlStreamDelegate del) : base(request, del, true)
		{
			if (Connections.ContainsKey(del.Name)) {
				KillConnection(del.Name);
			}
			Connections.Add(del.Name, this);			
		}		
开发者ID:21Off,项目名称:21Off,代码行数:7,代码来源:NSUrlConnectionWrapper.cs

示例2: RequestImage

		public bool RequestImage(string url, IImageUpdated receiver) {

			var local = RequestLocalImage(url);

			if (local != null) {
				receiver.UpdatedImage(url, local);
				return true;
			}

			if (pendingRequests.ContainsKey(url)){
				pendingRequests[url].Add(receiver);
			} else {
				pendingRequests.Add(url, new List<IImageUpdated>(){receiver});
			}
			NSUrlRequest req = new NSUrlRequest(new NSUrl(url), NSUrlRequestCachePolicy.ReturnCacheDataElseLoad, 10);
			new UrlConnection("img"+url, req, (UIImage img)=>{
				var surl = url;
				cache[surl] = img;
				var imgreq = pendingRequests[surl];
				foreach (var v in imgreq)
					v.UpdatedImage(surl, img);
				pendingRequests.Remove(surl);

			});
			return false;

		}
开发者ID:RobGibbens,项目名称:ArtekSoftware.Codemash,代码行数:27,代码来源:IImageUpdated.cs

示例3: SetupUserInterface

		private void SetupUserInterface ()
		{
			scrollView = new UIScrollView {
				BackgroundColor = UIColor.Clear.FromHexString ("#094074", 1.0f),
				Frame = new CGRect (0, 0, Frame.Width, Frame.Height * 2)
			};

			licensureLabel = new UILabel {
				Font = UIFont.FromName ("SegoeUI-Light", 25f),
				Frame = new CGRect (0, 20, Frame.Width, 35),
				Text = "Open-Source",
				TextAlignment = UITextAlignment.Center,
				TextColor = UIColor.White
			};

			string localHtmlUrl = Path.Combine (NSBundle.MainBundle.BundlePath, "Licensure.html");
			var url = new NSUrl (localHtmlUrl, false);
			var request = new NSUrlRequest (url);

			webView = new UIWebView () {
				Frame = new CGRect (0, 55, Frame.Width, Frame.Height - 55)
			};
			webView.LoadRequest (request);

			scrollView.ContentSize = new CGSize (Frame.Width, Frame.Height * 2);

			scrollView.Add (licensureLabel);
			scrollView.Add (webView);
			Add (scrollView);
		}
开发者ID:Cmaster14,项目名称:WilliesCycleApps,代码行数:30,代码来源:LicensureView.cs

示例4: DownloadFileAsync

		public async Task<nuint> DownloadFileAsync (Uri url, string destination)
		{
			this.Url = url.AbsoluteUri;
			if (downloadTask != null)
				return downloadTask.TaskIdentifier;
			if (session == null) {
				Initalize ();
			}
			Destination = destination;

			SessionId = session.Configuration.Identifier;
			if (!BackgroundDownloadManager.Tasks.TryGetValue (url.AbsoluteUri, out Tcs)) {
				Tcs = new TaskCompletionSource<bool> ();
				BackgroundDownloadManager.Tasks.Add (url.AbsoluteUri, Tcs);
				using (var request = new NSUrlRequest (new NSUrl (url.AbsoluteUri))) {
					downloadTask = session.CreateDownloadTask (request);
					downloadTask.Resume ();
				}
			}

			BackgroundDownloadManager.AddController (this.Url, this);

			await Tcs.Task;

			return downloadTask.TaskIdentifier; 
		}
开发者ID:Clancey,项目名称:iOSHelpers,代码行数:26,代码来源:BackgroundDownload.cs

示例5: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            NSUrl url1 = new NSUrl(url);
            NSUrlRequest request = new NSUrlRequest(url1);
            webView.LoadRequest(request);

            this.NavigationController.NavigationBar.Hidden =  false;
            this.NavigationController.NavigationBar.TintColor = UIColor.White;
            this.NavigationController.NavigationBar.BarTintColor = UIColor.FromRGB(44/255f,146/255f,208/255f);
            this.NavigationController.NavigationBar.BarStyle = UIBarStyle.Black;

            this.NavigationController.NavigationBar.TitleTextAttributes = new UIStringAttributes (){
                ForegroundColor = UIColor.White,
                Font = UIFont.FromName("System Bold",20.0f)
            };
            Title = name;
            this.NavigationItem.SetLeftBarButtonItem (new UIBarButtonItem(
                "Cancel", UIBarButtonItemStyle.Plain, (sender, args) => {
                    this.NavigationController.PopViewController(true);
                }), true);
            btn_close.TouchUpInside += (object sender, EventArgs e) => {

                this.NavigationController.PopViewController(true);
            };
        }
开发者ID:ppkdo,项目名称:sipper,代码行数:26,代码来源:WebViewController.cs

示例6: Open

        public void Open(string url, string protocol = null, string authToken = null)
        {
            try
            {
                if (_client != null)
                    Close();

                NSUrlRequest req = new NSUrlRequest(new NSUrl(url));
                if (!string.IsNullOrEmpty(authToken))
                {
                    NSMutableUrlRequest mutableRequest = new NSMutableUrlRequest(new NSUrl(url));
                    mutableRequest["Authorization"] = authToken;
                    req = (NSUrlRequest)mutableRequest.Copy();
                }

                if (string.IsNullOrEmpty(protocol))
                    _client = new WebSocket(req);
                else
                    _client = new WebSocket(req, new NSObject[] { new NSString(protocol) });

                _client.ReceivedMessage += _client_ReceivedMessage;
                _client.WebSocketClosed += _client_WebSocketClosed;
                _client.WebSocketFailed += _client_WebSocketFailed;
                _client.WebSocketOpened += _client_WebSocketOpened;

                _client.Open();
            }
            catch (Exception ex)
            {
                OnError(ex.Message);
            }
        }
开发者ID:NVentimiglia,项目名称:Websockets.PCL,代码行数:32,代码来源:WebsocketConnection.cs

示例7: ShouldStartLoad

        private bool ShouldStartLoad (NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            if (request.Url.AbsoluteString.StartsWith("app://resize"))
            {
                try
                {
                    var size = WebView.EvaluateJavascript("size();");
                    if (size != null)
                        nfloat.TryParse(size, out _height);

                    if (HeightChanged != null)
                        HeightChanged(_height);
                }
                catch
                {
                }

                return false;
            }

            if (!request.Url.AbsoluteString.StartsWith("file://"))
            {
                if (UrlRequested != null)
                    UrlRequested(request.Url.AbsoluteString);
                return false;
            }

            return true;
        }
开发者ID:jsuo,项目名称:CodeBucket,代码行数:29,代码来源:WebElement.cs

示例8: DownloadImage

        public void DownloadImage(string url)
        {
            indicatorView.StartAnimating();
            NSUrlRequest request = new NSUrlRequest(new NSUrl(url));

            new NSUrlConnection(request, new ConnectionDelegate(this), true);
        }
开发者ID:NotMyself,项目名称:FurnishlyApp,代码行数:7,代码来源:ProductTableViewCell.cs

示例9: ShouldStartLoad

 public override bool ShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
 {
     bool shouldStart = true;
     string url = request.Url.ToString();
     if (url.Contains("js-frame"))
     {
         shouldStart = false;
         string pendingArgs = bridge.webBrowser.EvaluateJavascript("window.locationMessenger.pendingArg.toString();");
         // Using JsonConvert.Deserialze<string[]> blows up under MonoTouch, so manually build the array of args instead
         JArray argsJArray = (JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(pendingArgs);
         string[] args = new string[argsJArray.Count];
         for (int i = 0; i < argsJArray.Count; i++)
             args[i] = (string)argsJArray[i];
         if (args[0] == "HandleScriptPropertyChanged")
         {
             if (args.Length == 3)
                 bridge.HandleScriptPropertyChanged(args[1], args[2], null);
             else
                 bridge.HandleScriptPropertyChanged(args[1], args[2], args[3]);
         }
         else if (args[0] == "InvokeViewModelIndexMethod")
             bridge.InvokeViewModelMethod(args[1], args[2], args[3]);
         else if (args[0] == "InvokeViewModelMethod")
             bridge.InvokeViewModelMethod(args[1], args[2]);
         else if (args[0] == "HandleDocumentReady")
             bridge.HandleDocumentReady();
         else if (args[0] == "HostLog")
             bridge.HostLog(args[1]);
         else
             SpinnakerConfiguration.CurrentConfig.Log(SpinnakerLogLevel.Error,"Ignoring unrecognized call from javascript for [" + args[0] + "] - this means that javascript in the view is trying to reach the host but with bad arguments");
     }
     return shouldStart;
 }
开发者ID:Claytonious,项目名称:spinnaker,代码行数:33,代码来源:ScriptObject.cs

示例10: CachedResponseForRequest

		public override NSCachedUrlResponse CachedResponseForRequest (NSUrlRequest request)
		{
			var uri = (Uri) request.Url;
			int index;

			if ((index = related.IndexOf (uri)) != -1) {
				var part = related[index] as MimePart;

				if (part != null) {
					var mimeType = part.ContentType.MimeType;
					var charset = part.ContentType.Charset;
					NSUrlResponse response;
					NSData data;

					using (var content = part.ContentObject.Open ())
						data = NSData.FromStream (content);

					response = new NSUrlResponse (request.Url, mimeType, (int) data.Length, charset);

					return new NSCachedUrlResponse (response, data);
				}
			}

			return base.CachedResponseForRequest (request);
		}
开发者ID:gphummer,项目名称:MimeKit,代码行数:25,代码来源:MultipartRelatedUrlCache.cs

示例11: AudioSelected

        public static UIViewController AudioSelected(ApiNode apiNode)
        {
            var url = apiNode["videoSrc1"];

            if (apiNode["contentNode"] != null)
            {
                url = apiNode[apiNode["contentNode"]];
            }

            //var videoController = new UIVideoController(url);

            //videoController.NavigationItem.Title = apiNode.Title;

            //return videoController;

            var vc = new UIViewController();

            var webView = new UIWebView(UIScreen.MainScreen.Bounds)
            {
                BackgroundColor = UIColor.White,
                ScalesPageToFit = true,
                AutoresizingMask = UIViewAutoresizing.All
            };

            var request = new NSUrlRequest(new NSUrl(url), NSUrlRequestCachePolicy.UseProtocolCachePolicy, 60);

            webView.LoadRequest(request);

            vc.NavigationItem.Title = apiNode.Title;

            vc.View.AutosizesSubviews = true;
            vc.View.AddSubview(webView);

            return vc;
        }
开发者ID:josiahpeters,项目名称:CCBoise,代码行数:35,代码来源:ApiVideoElement.cs

示例12: ViewWillAppear

		public override void ViewWillAppear (bool animated)
		{
			base.ViewWillAppear (animated);
			
			var urlRequest = new NSUrlRequest (new NSUrl (START_URL));
			_webView.LoadRequest (urlRequest);
		}
开发者ID:bpug,项目名称:LbkIos,代码行数:7,代码来源:FacebookViewController.cs

示例13: HandleShouldStartLoad

        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {
            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            const string scheme = "hybrid:";

            if (request.Url.Scheme != scheme.Replace (":", ""))
                return true;

            // This handler will treat everything between the protocol and "?"
            // as the method name.  The querystring has all of the parameters.
            var resources = request.Url.ResourceSpecifier.Split ('?');
            var method = resources [0];
            var parameters = System.Web.HttpUtility.ParseQueryString (resources [1]);

            if (method == "UpdateLabel") {
                var textbox = parameters ["textbox"];

                // Add some text to our string here so that we know something
                // happened on the native part of the round trip.
                var prepended = string.Format ("C# says: {0}", textbox);

                // Build some javascript using the C#-modified result
                var js = string.Format ("SetLabelText('{0}');", prepended);

                webView.EvaluateJavascript (js);
            }

            return false;
        }
开发者ID:neurospeech,项目名称:app-core-ios,代码行数:29,代码来源:WebViewController.cs

示例14: HandleShouldStartLoad

        bool HandleShouldStartLoad(UIWebView webView, NSUrlRequest request, UIWebViewNavigationType navigationType)
        {

            // If the URL is not our own custom scheme, just let the webView load the URL as usual
            var scheme = "app:";

            if (request.Url.Scheme != scheme.Replace(":", ""))
                return true;

            var resources = request.Url.ResourceSpecifier.Split('?');
            var method = resources[0];

            if (method == "QR")
            {
                var scanner = new ZXing.Mobile.MobileBarcodeScanner();
                scanner.Scan().ContinueWith(result => {
                    if (result != null){
                        var code = result.Result.Text;
                        this.InvokeOnMainThread(new NSAction(() => webView.LoadRequest(new NSUrlRequest(new NSUrl(MainUrl + "code?value=" + code)))));
                    }
                });
            }

            return false;
        }
开发者ID:artema,项目名称:hack4good,代码行数:25,代码来源:HybridViewController.cs

示例15: 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


注:本文中的NSUrlRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。