예제 #1
0
        public void OpenURI(string selectedText)
        {
            NSString searchText = new NSString(selectedText);

            searchText = searchText.CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8);
            Foundation.NSUrl url = new Foundation.NSUrl($"https://www.google.com/search?q={searchText}");
            UIApplication.SharedApplication.OpenUrl(url);
        }
예제 #2
0
        partial void WikiButtonClick(NSObject sender)
        {
            var      term      = SearchTerm.Trim();
            var      urlString = "https://www.google.com/search?q=" + term;
            NSString stringURL = new NSString(urlString);

            stringURL = stringURL.CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8);

            NSUrl url = new NSUrl(stringURL.ToString());

            if (url != null)
            {
                NSWorkspace.SharedWorkspace.OpenUrl(url);
            }
        }
예제 #3
0
        public static NSString UrlEncode(this string url)
        {
            NSString displayUrl = new NSString(url);

            return(displayUrl.CreateStringByAddingPercentEscapes(NSStringEncoding.ASCIIStringEncoding));
        }
예제 #4
0
		private async Task BegingDownloading(RequestData requestData, EventHandler<DownloadEventArgs> downloadedAction, Guid taskGuid)
		{
			NSUrlSession session = GetSession(requestData, downloadedAction);

			NSUrlSessionDownloadTask task;

			if (requestData.Type == RequestData.RequestType.Get)
			{
				NSString urlSting = new NSString(requestData.Url);

				urlSting = urlSting.CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8);

				task = session.CreateDownloadTask(NSUrl.FromString(urlSting));
			}
			else
			{
				NSMutableUrlRequest request = new NSMutableUrlRequest(NSUrl.FromString(requestData.Url))
				{
					Body = FormatBody(requestData.Body),
					HttpMethod = "POST"
				};

				task = session.CreateDownloadTask(request);
			}

			if (task != null)
			{
				task.TaskDescription = await JsonParser.SerializeToJsonString(new Dictionary<string, JsonValueInfo> { 
					{ "request", new JsonValueInfo(requestData.ToJson(), false) },
					{ "guid", new JsonValueInfo(taskGuid) }
				});

				task.Resume();
			}
			else
			{
				downloadedAction(this, new DownloadEventArgs("", taskGuid, requestData, "Can't create NSUrlSessionDownloadTask."));
			}
		}