• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# NSUrlRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: RequestStarted

		protected override void RequestStarted (NSUrlRequest request)
		{
			if(request.Url.AbsoluteString.TrimEnd('/').Equals(DeniedUrl))
			{
				_cancelled ();
				this.DismissViewController (true, null);
			}
		}
开发者ID:robertherber,项目名称:PersonalTasks,代码行数:8,代码来源:TrelloAuthenticationViewController.cs


示例17: ViewDidLoad

 public override void ViewDidLoad()
 {
     base.ViewDidLoad ();
     NSUrl url = new NSUrl (_urlAddress);
     NSUrlRequest request = new NSUrlRequest (url);
     this.webView.LoadRequest (request);
     // Perform any additional setup after loading the view, typically from a nib.
 }
开发者ID:markawil,项目名称:HCSUG_MonoApp,代码行数:8,代码来源:WebViewController.cs


示例18: Comms

 public Comms(string name, NSUrlRequest request, Action<string> success, Action failure)
     : base(request, new CommsDelegate(name, success, failure), true)
 {
     if (Connections.ContainsKey (name)) {
         KillConnection (name);
     }
     Connections.Add (name, this);
 }
开发者ID:rajeshwarn,项目名称:GhostPractice-iPadRepo,代码行数:8,代码来源:Comms.cs


示例19: UrlConnection

		public UrlConnection(string name, NSUrlRequest request, Action<string> success, Action failure, Action<NSUrlConnection, NSUrlAuthenticationChallenge> challenge) : base(request, new UrlDelegate(name, success, failure, challenge), true)
		{
			if (Connections.ContainsKey(name))
			{
				KillConnection(name);
			}

			Connections.Add(name, this);
		}
开发者ID:CartBlanche,项目名称:MonoMobile.MVVM,代码行数:9,代码来源:UrlConnection.cs


示例20: CanInitWithRequest

        public new static bool CanInitWithRequest(NSUrlRequest request)
        {
            if (request.Url.Scheme.Equals("https", StringComparison.CurrentCultureIgnoreCase))
            {
                return GetProperty("MsalCustomUrlProtocol", request) == null;
            }

            return false;
        }
开发者ID:AzureAD,项目名称:microsoft-authentication-library-for-dotnet,代码行数:9,代码来源:MsalCustomUrlProtocol.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NSUrlSession类代码示例发布时间:2022-05-24
下一篇:
C# NSUrlConnection类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap