private void CheckConnectionStatus(bool fireMissiles = true) { var internetStatus = Reachability.InternetConnectionStatus(); switch (internetStatus) { case NetworkStatus.NotReachable: ChangeConnectivityStatus(false, false, false, fireMissiles); break; case NetworkStatus.ReachableViaCarrierDataNetwork: ChangeConnectivityStatus(true, false, true, fireMissiles); break; case NetworkStatus.ReachableViaWiFiNetwork: ChangeConnectivityStatus(true, true, false, fireMissiles); break; } }
private static void SendMyBookmarks(List <Book> bookList) { if (cancelled) { SetSent(true); CheckSentDone(); } else { if (Reachability.IsDefaultNetworkAvailable()) { SaveMyStuff.SetMyBookmarksEvent += HandleSetMyBookmarksEvent; foreach (Book book in bookList) { List <Bookmark> bookmarkList = BooksOnDeviceAccessor.GetAllBookmarks(book.ID); if (bookmarkList != null && bookmarkList.Count > 0) { SaveMyStuff.SetMyBookmarks(bookmarkList); } else { sentBookmarks = true; } } // Remove bookmarks that are marked as removed foreach (Book book in bookList) { List <Bookmark> bookmarkList = BooksOnDeviceAccessor.GetRemovedBookmarks(book.ID); if (bookmarkList != null && bookmarkList.Count > 0) { foreach (Bookmark bookmark in bookmarkList) { BooksOnDeviceAccessor.RemoveBookmark(bookmark.BookID, bookmark.PageID); } } } } } }
public void GetData() { if (Reachability.IsHostReachable("www.codecags.com")) { var client = new RestClient("http://www.codecags.com"); var request = new RestRequest("jsonTienda.php", Method.GET); request.RequestFormat = DataFormat.Json; var response = client.Execute(request); RestSharp.Deserializers.JsonDeserializer deserial = new JsonDeserializer(); jsonObj = deserial.Deserialize <List <JsonTienda> > (response); } else { var alert = new UIAlertView("Connection Error", "Unable to connect to server", null, "OK", new string[] { "Cancel" }); alert.Clicked += (s, b) => { Console.WriteLine("Button " + b.ButtonIndex.ToString() + " clicked"); }; alert.Show(); } }
public void ReachabilityTable_must_have_correct_aggregated_status() { var records = ImmutableList.Create( new Reachability.Record(nodeA, nodeB, Reachability.ReachabilityStatus.Reachable, 2), new Reachability.Record(nodeC, nodeB, Reachability.ReachabilityStatus.Unreachable, 2), new Reachability.Record(nodeA, nodeD, Reachability.ReachabilityStatus.Unreachable, 3), new Reachability.Record(nodeD, nodeB, Reachability.ReachabilityStatus.Terminated, 4) ); var versions = ImmutableDictionary.CreateRange(new[] { new KeyValuePair <UniqueAddress, long>(nodeA, 3), new KeyValuePair <UniqueAddress, long>(nodeC, 3), new KeyValuePair <UniqueAddress, long>(nodeD, 4) }); var r = new Reachability(records, versions); Assert.Equal(Reachability.ReachabilityStatus.Reachable, r.Status(nodeA)); Assert.Equal(Reachability.ReachabilityStatus.Terminated, r.Status(nodeB)); Assert.Equal(Reachability.ReachabilityStatus.Unreachable, r.Status(nodeD)); }
public static bool Download(String url, UIViewController controller, bool forceDownload = false) { bool exist = false; if (!String.IsNullOrEmpty(url) && url.Contains("http")) { try { String localPath = DownloadedFilesCache.BuildCachedFilePath(url); if (File.Exists(localPath) && !forceDownload) { exist = true; } else { if (Reachability.IsDefaultNetworkAvailable()) { BackgroundWorker downloadWorker = new BackgroundWorker(); downloadWorker.DoWork += delegate { ASIHTTPRequest request = new ASIHTTPRequest(NSUrl.FromString(url)); request.Username = Settings.UserID; request.Password = KeychainAccessor.Password; request.Domain = Settings.Domain; request.Delegate = controller; request.DidFinishSelector = new Selector("requestFinish:"); request.DownloadDestinationPath = DownloadedFilesCache.BuildCachedFilePath(url); request.StartAsynchronous(); }; downloadWorker.RunWorkerAsync(); } } } catch (Exception ex) { Logger.WriteLineDebugging("FileDownloader - Download: {0}", ex.ToString()); } } return(exist); }
private NetworkConnectivityLevel GetNetworkConnectivityLevelImpl() { var mobileDataRestricted = false; #if __IOS__ && !__MACCATALYST__ // catalyst https://github.com/xamarin/xamarin-macios/issues/13931 mobileDataRestricted = NetworkInformation.CellularData.RestrictedState == CTCellularDataRestrictedState.Restricted; #endif var internetStatus = Reachability.InternetConnectionStatus(); if ((internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork && !mobileDataRestricted) || internetStatus == NetworkStatus.ReachableViaWiFiNetwork) { return(NetworkConnectivityLevel.InternetAccess); } var remoteHostStatus = Reachability.RemoteHostStatus(); if ((remoteHostStatus == NetworkStatus.ReachableViaCarrierDataNetwork && !mobileDataRestricted) || remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork) { return(NetworkConnectivityLevel.InternetAccess); } return(NetworkConnectivityLevel.None); }
public void GetPromoData() { if (!Reachability.IsHostReachable("www.codecags.com")) { var alert = new UIAlertView { Title = "Unable to connect to server", Message = "Verify network connections" }; alert.AddButton("OK"); alert.Show(); } else { var client = new RestClient("http://codecags.com"); var request = new RestRequest("jsonAllPromos.php", Method.POST); request.RequestFormat = DataFormat.Json; var response = client.Execute(request); RestSharp.Deserializers.JsonDeserializer deserial = new JsonDeserializer(); promos = deserial.Deserialize <List <JsonPromos> > (response); } }
/// <summary> /// Called when a row is touched /// </summary> public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { tableView.DeselectRow(indexPath, true); if (!Reachability.IsHostReachable("www.Amazon.com")) { new UIAlertView(Utils.GetStringFromMainBundle("CFBundleDisplayName"), "Cannot connect to Amazon", null, "OK", null).Show(); return; } // show customer review var detail = mParentViewController.Storyboard.InstantiateViewController("CustomerReviews") as CustomerReviewsViewCtrl; detail.Title = mTableItems [indexPath.Row].Title; detail.SetItemId(mTableItems [indexPath.Row].Id); mParentViewController.NavigationController.PushViewController( detail, true ); }
private NetworkConnectivityLevel GetNetworkConnectivityLevelImpl() { var mobileDataRestricted = false; #if __IOS__ mobileDataRestricted = NetworkInformation.CellularData.RestrictedState == CTCellularDataRestrictedState.Restricted; #endif var internetStatus = Reachability.InternetConnectionStatus(); if ((internetStatus == NetworkStatus.ReachableViaCarrierDataNetwork && !mobileDataRestricted) || internetStatus == NetworkStatus.ReachableViaWiFiNetwork) { return(NetworkConnectivityLevel.InternetAccess); } var remoteHostStatus = Reachability.RemoteHostStatus(); if ((remoteHostStatus == NetworkStatus.ReachableViaCarrierDataNetwork && !mobileDataRestricted) || remoteHostStatus == NetworkStatus.ReachableViaWiFiNetwork) { return(NetworkConnectivityLevel.InternetAccess); } return(NetworkConnectivityLevel.None); }
async public void LoadBooks() { TimeSpan diff = DateTime.UtcNow.Subtract(Settings.AvailableCheckTime); if (TimeSettings.LibraryRefreshRequired(diff)) { if (Reachability.IsDefaultNetworkAvailable()) { LoadingView.Show("Loading", "Please wait while we're checking Available Books...", false); List <Book> bookList = await eBriefingService.Run(() => eBriefingService.StartDownloadBooks()); if (bookList != null) { Settings.AvailableCheckTime = DateTime.UtcNow; // Save in the cache BooksOnServerAccessor.SaveBooks(bookList); // Load books RetrieveBooks(); // Update available badge UpdateAvailableBadge(); } else { LoadingView.Hide(); } } else { UpdateStatusLabel(StringRef.connectionRequired); } } else { RetrieveBooks(); } }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { UITableViewCell celda = tableView.DequeueReusableCell(Identificador); if (celda == null) { celda = new UITableViewCell(UITableViewCellStyle.Subtitle, Identificador); } celda.SelectionStyle = UITableViewCellSelectionStyle.Blue; celda.TextLabel.Text = ListaDatos [indexPath.Row].nombre; celda.Accessory = UITableViewCellAccessory.DisclosureIndicator; if (Reachability.IsHostReachable("www.codecags.com")) { celda.ImageView.SetImage( url: new NSUrl("http://www.codecags.com/Img/" + ListaDatos [indexPath.Row].logo), placeholder: UIImage.FromBundle("placeholder.jpg") ); } celda.DetailTextLabel.Text = "Promociones disponibles: " + ListaDatos [indexPath.Row].promociones.ToString(); celda.DetailTextLabel.TextColor = UIColor.Gray; return(celda); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. View.BackgroundColor = UIColor.White; Title = "Movie Searching App "; TableView.Source = new TableSource(this); TableView.RowHeight = UITableView.AutomaticDimension; TableView.EstimatedRowHeight = 400f; TableView.SeparatorStyle = 0; searchBar = new UISearchBar(); searchBar.Placeholder = "Enter Movie Title"; searchBar.SizeToFit(); searchBar.AutocorrectionType = UITextAutocorrectionType.No; searchBar.AutocapitalizationType = UITextAutocapitalizationType.None; searchBar.SearchButtonClicked += (sender, e) => { // check whetehr seach has string or not if (!string.IsNullOrEmpty(searchBar.Text)) { // first check network if (Reachability.IsNetworkAvailable()) { Search(); } else { new UIAlertView("", "No network connection is available. Please check your netowrk.", null, "OK").Show(); } } else { new UIAlertView("", "Please enter searching string", null, "OK").Show(); } }; TableView.TableHeaderView = searchBar; }
public override void ViewDidLoad() { base.ViewDidLoad(); webView.ShouldStartLoad = HandleShouldStartLoad; Reachability.ReachabilityChanged += (sender, e) => { if (Reachability.InternetConnectionStatus() != NetworkStatus.NotReachable) { webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); } else { UIAlertView alert = new UIAlertView(); alert.Title = "Sem ligação à rede"; alert.AddButton("Continuar"); alert.Message = "Não conseguirá usar a aplicação sem conexão à rede."; alert.Show(); } }; // Perform any additional setup after loading the view, typically from a nib. }
async void TechnicalSpecButton_TouchUpInside(object sender, EventArgs e) { //Get current view controller var window = UIApplication.SharedApplication.KeyWindow; var vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } SpecResponse specResponse = new SpecResponse(); var specification = await specResponse.GetSpecBySpecIDDesignationIDAsync(ad.SpecId, ad.DesignationId); if (specification.SpecId != 0) { var specTableViewController = vc.Storyboard.InstantiateViewController("SpecViewController_") as SpecViewController_; specTableViewController.Spec = specification; vc.PresentViewController(specTableViewController, true, null); } else { if (!Reachability.IsHostReachable(Settings._baseDomain)) { var alert = UIAlertController.Create("Connect to a Network", "Please connect to a network to retrieve these aircraft specs", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, null)); if (alert.PopoverPresentationController != null) { alert.PopoverPresentationController.SourceView = vc.View; alert.PopoverPresentationController.PermittedArrowDirections = UIPopoverArrowDirection.Up; } vc.PresentViewController(alert, animated: true, completionHandler: null); } } }
public void ReachabilityTable_must_merge_versions_correctly() { var r1 = new Reachability(ImmutableList.Create <Reachability.Record>(), new Dictionary <UniqueAddress, long> { { nodeA, 3 }, { nodeB, 5 }, { nodeC, 7 } }.ToImmutableDictionary()); var r2 = new Reachability(ImmutableList.Create <Reachability.Record>(), new Dictionary <UniqueAddress, long> { { nodeA, 6 }, { nodeB, 2 }, { nodeD, 1 } }.ToImmutableDictionary()); var merged = r1.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r2); var expected = new Dictionary <UniqueAddress, long> { { nodeA, 6 }, { nodeB, 5 }, { nodeC, 7 }, { nodeD, 1 } }.ToImmutableDictionary(); Assert.Equal(expected, merged.Versions); var merged2 = r2.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r1); Assert.Equal(expected, merged2.Versions); }
public void RetrieveBooks() { if (!Reachability.IsDefaultNetworkAvailable()) { UpdateStatusLabel(StringRef.connectionRequired); } else { List <Book> bookList = BooksOnServerAccessor.GetBooks(); if (bookList == null) { UpdateStatusLabel("There are no available books."); Failed2RetrieveBooks(); } else { // Load collectionView LoadCollectionView(); } } }
public static bool CanReach(this Reachability reachability, IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams) { // NOTE: not checking reachability.working if (traverseParams.thing != null) { if (!traverseParams.thing.Spawned) { return(false); } // ERROR: thing.map != this.map } if (ReachabilityImmediate.CanReachImmediate(start, dest, reachability.GetMap(), peMode, traverseParams.thing)) { return(true); } if (!dest.IsValid) { return(false); } if (dest.HasThing && dest.Thing.Map != reachability.GetMap()) { return(false); } if (!start.InBounds(reachability.GetMap()) || !dest.Cell.InBounds(reachability.GetMap())) { return(false); } if (peMode == PathEndMode.OnCell || peMode == PathEndMode.Touch || peMode == PathEndMode.ClosestTouch) { Room room = RegionAndRoomQuery.RoomAtFast(start, reachability.GetMap(), RegionType.Set_Passable); if (room != null && room == RegionAndRoomQuery.RoomAtFast(dest.Cell, reachability.GetMap(), RegionType.Set_Passable)) { return(true); } } return(true); // TEMP }
public void PurchaseProduct(SKProduct product) { try { if (Reachability.InternetConnectionStatus() == NetworkStatus.NotReachable) { Logger.Log("ERROR: PurchaseProduct: No open internet connection is available."); using (var alert = new UIAlertView("ERROR", "No open internet connection is available.", null, "OK", null)) alert.Show(); return; } if (!CanMakePayments()) { Logger.Log("ERROR: PurchaseProduct: Cannot make payments"); using (var alert = new UIAlertView("ERROR", "Sorry but you cannot make purchases from the In App Billing store. Please try again later.", null, "OK", null)) alert.Show(); return; } if (product == null) { Logger.Log("ERROR: PurchaseProduct: Product is null"); return; } Logger.Log("PurchaseProduct: Product ID: " + product.ProductIdentifier); SKPayment payment = SKPayment.CreateFrom(product); SKPaymentQueue.DefaultQueue.AddPayment(payment); } catch (Exception ex) { Logger.Log("ERROR: PurchaseProduct: " + ex); } }
protected async override void OnAppearing() { if (Reachability.IsHostReachable("http://www.google.co.uk")) { Online = true; ActivityIndicatorSurveyPage.IsRunning = true; string Response = ""; ISurveyQuestion Survey = new SurveyQuestionsHandler(); string AllSurveyQuestions = await Task.Run(() => Response = Survey.GetAllQuesitons(SurveyId)); ActivityIndicatorSurveyPage.IsRunning = false; MainStackLayout.IsVisible = true; if (!(AllSurveyQuestions == "Unauthorized" || AllSurveyQuestions == "No Content" || AllSurveyQuestions == "No Internet Connection")) { AllSurveys = JsonConvert.DeserializeObject <IEnumerable <cSurveyQuestions> >(AllSurveyQuestions.ToString()); CreateAllQuestions(AllSurveys); FullStackLayout.IsVisible = true; } else { SurveyEmptyStacklayout.IsVisible = true; } } else { var ListOfSurveyQuestions = dbHandler.GetAllQuestionBySurveyId(SurveyId); if (ListOfSurveyQuestions.Count > 0) { CreateAllQuestions(ListOfSurveyQuestions); FullStackLayout.IsVisible = true; MainStackLayout.IsVisible = true; } else { SurveyEmptyStacklayout.IsVisible = true; } } }
public override void WillTerminate(UIApplication application) { // Called when the application is about to terminate. Save data, if needed. See also DidEnterBackground. try { if (ion.dataLogManager.isRecording) { var done = ion.dataLogManager.StopRecording().Result; } if (!ion.preferences.portal.rememberMe) { ion.preferences.portal.userId = -1; ion.preferences.portal.username = ""; ion.preferences.portal.password = ""; } if (Reachability.LocalWifiConnectionStatus() == NetworkStatus.ReachableViaWiFiNetwork) { try { Log.UploadLogs(); } catch (Exception ee) { Log.E(this, "Failed to upload logs", ee); } } if (ion is RemoteIosION) { var remote = ion as RemoteIosION; ion.portal.LogoutAsync().Wait(); } else { ion.SaveWorkbenchAsync().Wait(); } ion.Dispose(); } catch (Exception e) { Log.E(this, "Failed to terminate ion instance", e); } }
async private void StartAuthentication() { if (Reachability.IsDefaultNetworkAvailable()) { if (!String.IsNullOrEmpty(URL.ServerURL)) { bool verified = await eBriefingService.Run(() => CheckCredential()); if (verified) { Dismiss(); } else { ShowErrorView(); } } } else { ShowErrorView(); } }
public override void RunAlgorithm(IGraph graph) { ResetGraph(graph); if (graph.Nodes.Any()) { if (markedSource == null || !graph.Contains(markedSource)) { markedSource = graph.Nodes.First(); } } var result = new Reachability { Directed = Directed, StartNodes = { Item = markedSource } }.Run(graph); foreach (var node in result.ReachableNodes) { node.Tag = new Tag { CurrentColor = Colors.Blue, IsSource = node == markedSource }; } foreach (var edge in graph.Edges) { if (result.IsReachable(edge.GetSourceNode()) && result.IsReachable(edge.GetTargetNode())) { edge.Tag = new Tag { CurrentColor = Colors.Blue, Directed = Directed }; } } }
public override async void PressedSendButton(UIButton button, string text, string senderId, string senderDisplayName, NSDate date) { if (!Reachability.IsNetworkAvailable()) { new UIAlertView("Alert", "Please check your internet connection!", null, "Ok", null).Show(); return; } SystemSoundPlayer.PlayMessageSentSound(); if (client == null) { CreateMqttConnection(); } client.Publish(TOPIC_PUBLISH, Encoding.UTF8.GetBytes(text), MqttMsgBase.QOS_LEVEL_AT_LEAST_ONCE, false); var message = new Message(SenderId, SenderDisplayName, NSDate.Now, text); if (message != null) { messages.Add(message); var conn = new SQLiteConnection(ChatterDatabase.DatabasePath()); var s = conn.Insert(new ChatUserModel() { Id = SenderId, DisplayName = SenderDisplayName, ChatDate = DateTime.Now, Text = text }); } FinishSendingMessage(true); await Task.Delay(500); }
public void RunCommand(string strCommand) { if (strCommand == "MMP") { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "pnt files (*.pnt)|*.pnt| All files (*.*)|*.*"; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { Marking M0 = PetriNetOperator.GetInitialMarkingFromPntFile(dialog.FileName); Reachability gra = new Reachability(M0); MMPCaculate mmp = new MMPCaculate(gra); mmp.ExportStateFile(); RootApp.UI.UI.ShowDebugText("Success export state file."); mmp.ExportMMPILPFile(true); RootApp.UI.UI.ShowDebugText("Success export MMP ILP files."); } } else if (strCommand == "NMMP") { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "pnt files (*.pnt)|*.pnt| All files (*.*)|*.*"; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { Marking M0 = PetriNetOperator.GetInitialMarkingFromPntFile(dialog.FileName); Reachability gra = new Reachability(M0); NMMPCaculate nmmp = new NMMPCaculate(gra); nmmp.ExportStateFile(); RootApp.UI.UI.ShowDebugText("Success export state file."); nmmp.ExportNMMPILPFile(); RootApp.UI.UI.ShowDebugText("Success export NMMP ILP files."); nmmp.ExportXls(); RootApp.UI.UI.ShowDebugText("Success export excel file."); } } }
private static BoolUnknown GetCachedResult(Reachability __instance, TraverseParms traverseParams, List <Region> startingRegionsParams, List <Region> destRegionsParams) { bool flag = false; ReachabilityCache cache = __instance.cache; for (int i = 0; i < startingRegionsParams.Count; i++) { for (int j = 0; j < destRegionsParams.Count; j++) { if (destRegionsParams[j] == startingRegionsParams[i]) { return(BoolUnknown.True); } #if RW12 switch (cache.CachedResultFor(startingRegionsParams[i].Room, destRegionsParams[j].Room, traverseParams)) #endif #if RW13 switch (cache.CachedResultFor(startingRegionsParams[i].District, destRegionsParams[j].District, traverseParams)) #endif { case BoolUnknown.True: return(BoolUnknown.True); case BoolUnknown.Unknown: flag = true; break; } } } if (!flag) { return(BoolUnknown.False); } return(BoolUnknown.Unknown); }
private async void OnDownload(object sender, EventArgs e) { try { if (Reachability.InternetConnectionStatus() != ReachabilityNetworkStatus.NotReachable) { var objSender = (Button)sender; DocumentViewModel documentListViewModel = (DocumentViewModel)objSender.BindingContext; if (documentListViewModel != null) { int selectedItemIndex = _lstDocuments.IndexOf(documentListViewModel); documentListViewModel.DownloadState = DocumentDownloadState.Inprogress; _lstDocuments[selectedItemIndex] = documentListViewModel; if (await AppData.PropertyModel.GetDocument(documentListViewModel.SriDocument)) { documentListViewModel.DownloadState = DocumentDownloadState.Completed; } else { documentListViewModel.DownloadState = DocumentDownloadState.Begin; } if (_lstDocuments.Count != 0) { _lstDocuments[selectedItemIndex] = documentListViewModel; } } } else { await SplitView.DisplayAlert("No network", " Check network before downloading document", "OK", null); } } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
protected override void OnElementChanged(ElementChangedEventArgs <Image> e) { base.OnElementChanged(e); UIImage image; var networkStatus = Reachability.InternetConnectionStatus(); var isReachable = networkStatus != NetworkStatus.NotReachable; if (isReachable) { image = GetImageFromWeb(WebImage.ImageUrl); } else { image = string.IsNullOrEmpty(WebImage.DefaultImage) ? new UIImage() : UIImage.FromBundle(WebImage.DefaultImage); } var imageView = new UIImageView(image); SetNativeControl(imageView); }
public static void hijackClearCache(this Reachability oldReacher) { int ticket = -1; String index = ""; try { FieldInfo mapField = typeof(Reachability).GetField("map", BindingFlags.NonPublic | BindingFlags.Instance); Map map = (Map)mapField.GetValue(oldReacher); index = map.GetUniqueLoadID(); var reacher = ReachabilityInstanceContrainer.GetInstance().requestReacher(index, ref ticket, map); reacher.ClearCache(); ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket); } catch (Exception e) { if (ticket != -1 && !index.NullOrEmpty()) { ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket); } throw e; } }
public static bool hijackCanReachUnfogged(this Reachability oldReacher, IntVec3 c, TraverseParms traverseParms) { int ticket = -1; String index = ""; try { FieldInfo mapField = typeof(Reachability).GetField("map", BindingFlags.NonPublic | BindingFlags.Instance); Map map = (Map)mapField.GetValue(oldReacher); var reacher = ReachabilityInstanceContrainer.GetInstance().requestReacher(index, ref ticket, map); var result = reacher.CanReachUnfogged(c, traverseParms); ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket); return(result); } catch (Exception e) { if (ticket != -1 && !index.NullOrEmpty()) { ReachabilityInstanceContrainer.GetInstance().CheckInReacher(index, ticket); } throw e; } }
public TUM(IntPtr handle) : base(handle) { Title = NSBundle.MainBundle.LocalizedString("TUM", "TUM"); View.BackgroundColor = UIColor.White; webView = new UIWebView(View.Bounds); webView.ScrollView.ContentInset = new UIEdgeInsets(0, 0, 45, 0); View.AddSubview(webView); url = "http://ios.tum.pt/index.html"; webView.ScalesPageToFit = true; if (!Reachability.IsHostReachable("tum.pt")) { UIAlertView alert = new UIAlertView(); alert.Title = "Sem ligação à rede"; alert.AddButton("Continuar"); alert.Message = "Não conseguirá usar a aplicação sem conexão à rede."; alert.Show(); } else { webView.LoadRequest(new NSUrlRequest(new NSUrl(url))); } }
public void ReachabilityTable_must_merge_versions_correctly() { var r1 = new Reachability(ImmutableList.Create<Reachability.Record>(), new Dictionary<UniqueAddress, long> { { nodeA, 3 }, { nodeB, 5 }, { nodeC, 7 } }.ToImmutableDictionary()); var r2 = new Reachability(ImmutableList.Create<Reachability.Record>(), new Dictionary<UniqueAddress, long> { { nodeA, 6 }, { nodeB, 2 }, { nodeD, 1 } }.ToImmutableDictionary()); var merged = r1.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r2); var expected = new Dictionary<UniqueAddress, long> { { nodeA, 6 }, { nodeB, 5 }, { nodeC, 7 }, { nodeD, 1 } }.ToImmutableDictionary(); merged.Versions.Should().Equal(expected); var merged2 = r2.Merge(ImmutableHashSet.Create(nodeA, nodeB, nodeC, nodeD, nodeE), r1); merged2.Versions.Should().Equal(expected); }
public void ReachabilityTable_must_have_correct_aggregated_status() { var records = ImmutableList.Create( new Reachability.Record(nodeA, nodeB, Reachability.ReachabilityStatus.Reachable, 2), new Reachability.Record(nodeC, nodeB, Reachability.ReachabilityStatus.Unreachable, 2), new Reachability.Record(nodeA, nodeD, Reachability.ReachabilityStatus.Unreachable, 3), new Reachability.Record(nodeD, nodeB, Reachability.ReachabilityStatus.Terminated, 4)); var versions = ImmutableDictionary.CreateRange(new[] { new KeyValuePair<UniqueAddress, long>(nodeA, 3), new KeyValuePair<UniqueAddress, long>(nodeC, 3), new KeyValuePair<UniqueAddress, long>(nodeD, 4) }); var r = new Reachability(records, versions); r.Status(nodeA).Should().Be(Reachability.ReachabilityStatus.Reachable); r.Status(nodeB).Should().Be(Reachability.ReachabilityStatus.Terminated); r.Status(nodeD).Should().Be(Reachability.ReachabilityStatus.Unreachable); }
// Use this for initialization void Awake() { instance = this; DontDestroyOnLoad(gameObject); }
/// <summary> /// Gets a list of podcasts from local storage or online. /// </summary> private void GetPodcastList() { var r = new Reachability(); var HasConnection = r.IsHostReachable("www.google.com"); if(HasConnection) { Console.WriteLine ("Have connection - get internet version"); _webClient = new WebClient(); // Make Async... var url = _hanselminuteMp3RssFeed; _webClient.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e) { SaveOnDevice(e.Result); DisplayPodcastList (e.Result); StopLoadingScreen(); StopInternetActivity(); }; _webClient.DownloadStringAsync(new Uri(url)); } else if (!HasConnection && HasLocalXml()) { Console.WriteLine ("No connection but use local version"); DisplayPodcastList(GetLocalPodcastListXml()); } else { Console.WriteLine ("No internet - no local version"); using (var alert = new UIAlertView("Whoops", "You'll need to connect to the internet to get a list of Podcasts", null, "Ok", null)) { alert.Dismissed += delegate { Console.WriteLine ("Dismissed Alert"); StopInternetActivity(); StopLoadingScreen(); }; alert.Show(); } } }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var url = _podcastList[indexPath.Row].Url; var fileName = Path.GetFileNameWithoutExtension(url); var offlineFilePath = Path.Combine(_hvc._documents, fileName + ".mp3"); Console.WriteLine ("Selected " + _podcastList[indexPath.Row].Title); var r = new Reachability(); if(!r.IsHostReachable("www.google.com") && _hvc.OfflineMp3Available(offlineFilePath)) _hvc.PlayAudioUrl(url); else if(!r.IsHostReachable("www.google.com")) { using (var alert = new UIAlertView("Whoops", "You'll need to be on the internet to do this", null, "Ok", null)) { alert.Show(); } } else _hvc.PlayAudioUrl(url); tableView.DeselectRow(indexPath, true); }
public void ReachabilityTableMustHaveCorrectAggregatedStatus() { var records = ImmutableList.Create( new Reachability.Record(nodeA, nodeB, Reachability.ReachabilityStatus.Reachable, 2), new Reachability.Record(nodeC, nodeB, Reachability.ReachabilityStatus.Unreachable, 2), new Reachability.Record(nodeA, nodeD, Reachability.ReachabilityStatus.Unreachable, 3), new Reachability.Record(nodeD, nodeB, Reachability.ReachabilityStatus.Terminated, 4) ); var versions = ImmutableDictionary.CreateRange(new[] { new KeyValuePair<UniqueAddress, long>(nodeA, 3), new KeyValuePair<UniqueAddress, long>(nodeC, 3), new KeyValuePair<UniqueAddress, long>(nodeD, 4) }); var r = new Reachability(records, versions); Assert.Equal(Reachability.ReachabilityStatus.Reachable, r.Status(nodeA)); Assert.Equal(Reachability.ReachabilityStatus.Terminated, r.Status(nodeB)); Assert.Equal(Reachability.ReachabilityStatus.Unreachable, r.Status(nodeD)); }