/// <summary> /// Extract first child path, i.e. text before first separator. /// </summary> /// <param name="path">The inital path.</param> /// <param name="remainder">The remainder of the path after extraction.</param> /// <returns>The text before the first separator.</returns> public static FacebookObjectId ExtractFirstChildPath(string path, out string remainder) { string childPath = path; remainder = String.Empty; if (!string.IsNullOrEmpty(path)) { int separatorIndex = path.IndexOf("/", StringComparison.Ordinal); if (separatorIndex >= 0 && separatorIndex < path.Length) { // Separator was found, remainder of the path is passed to the matching child for further lookup childPath = path.Substring(0, separatorIndex); if (separatorIndex + 1 < path.Length) { remainder = path.Substring(separatorIndex + 1, path.Length - (separatorIndex + 1)); } } } if (!string.IsNullOrEmpty(childPath)) { childPath = Uri.UnescapeDataString(childPath); } return(FacebookObjectId.Create(childPath)); }
private Navigator _TryGetNavigatorFromPhotoUri(Uri uri) { if (uri.LocalPath.ToLowerInvariant().Equals("/photo.php")) { string userId = null; string photoId = null; string id = null; foreach (string part in uri.Query.Split('?', '&')) { if (part.ToLowerInvariant().StartsWith("id=")) { userId = part.Substring("id=".Length); } else if (part.ToLowerInvariant().StartsWith("pid=")) { photoId = part.Substring("pid=".Length); } } if (userId != null && photoId != null) { // Need to do additional parsing here. // If id is 32 bits then PID = ((id << 32) | pid) // If id is 64 bits then PID = id + " _ " + pid ulong userIdLong; if (ulong.TryParse(userId, out userIdLong)) { if (userIdLong == (ulong)(uint)userIdLong) { uint photoIdInt; if (uint.TryParse(photoId, out photoIdInt)) { id = ((userIdLong << 32) | (ulong)photoIdInt).ToString(); } } else { id = userId + "_" + photoId; } } } if (!string.IsNullOrEmpty(id)) { FacebookObjectId fbUserId = FacebookObjectId.Create(userId); FacebookObjectId fbPhotoId = FacebookObjectId.Create(id); Navigator nav = ((PhotoAlbumCollectionNavigator)ViewManager.MasterNavigator.PhotoAlbumsNavigator).GetPhotoWithId(fbUserId, fbPhotoId); if (nav != null) { return(nav); } } } return(null); }
public MasterNavigator(ViewManager viewManager, FacebookService facebookService, ViewPage startupPage) { Verify.IsNotNull(viewManager, "viewManager"); Verify.IsNotNull(facebookService, "facebookService"); _viewManager = viewManager; HomeNavigator = new HomePage().GetNavigator(null, facebookService.Dispatcher); PhotoAlbumsNavigator = new PhotoAlbumCollectionNavigator(facebookService.PhotoAlbums, FacebookObjectId.Create("Photo Albums"), null); FriendsNavigator = new ContactCollectionNavigator(facebookService.Friends, FacebookObjectId.Create("Friends"), null); ProfileNavigator = new ContactNavigator(facebookService.MeContact, FacebookObjectId.Create("Me"), null); _children = new[] { HomeNavigator, PhotoAlbumsNavigator, FriendsNavigator, ProfileNavigator }; Navigator startupNavigator = null; switch (startupPage) { case ViewPage.Friends: startupNavigator = FriendsNavigator; _startupCollection = facebookService.Friends; break; case ViewPage.Newsfeed: startupNavigator = HomeNavigator; _startupCollection = facebookService.NewsFeed; break; case ViewPage.Photos: startupNavigator = PhotoAlbumsNavigator; _startupCollection = facebookService.PhotoAlbums; break; case ViewPage.Profile: startupNavigator = ProfileNavigator; _startupCollection = null; break; } _loadingPage = new LoadingPage(startupNavigator); if (_startupCollection != null) { _startupCollection.CollectionChanged += _SignalNewsfeedChanged; } else { _loadingPage.Signal(); } _loginPage = new LoginPage(facebookService.ApplicationId, facebookService.ApplicationKey, _loadingPage.GetNavigator()); LoginPageNavigator = _loginPage.Navigator; }
private Navigator _TryGetNavigatorFromProfileUri(Uri uri) { FacebookObjectId fbId = default(FacebookObjectId); // Maybe this is a straight-up profile.php?id=#### if (uri.LocalPath.ToLowerInvariant().Equals("/profile.php")) { string id = null; string idPart = null; foreach (string part in new[] { "?id=", "&id=" }) { if (uri.Query.ToLowerInvariant().Contains(part)) { idPart = part; break; } } if (idPart != null) { id = uri.Query.ToLower(); id = uri.Query.Substring(id.IndexOf(idPart) + idPart.Length); // Strip out the rest of the query id = id.Split('&')[0]; fbId = FacebookObjectId.Create(id); } if (FacebookObjectId.IsValid(fbId)) { var me = (FacebookContact)ViewManager.MasterNavigator.ProfileNavigator.Content; if (me.UserId.Equals(fbId)) { return(ViewManager.MasterNavigator.ProfileNavigator); } Navigator nav = ((ContactCollectionNavigator)ViewManager.MasterNavigator.FriendsNavigator).GetContactWithId(fbId); if (nav != null) { return(nav); } } } return(null); }
public SearchNavigator(SearchResults searchResults) : base(searchResults, FacebookObjectId.Create("[search]" + searchResults.SearchText), null) { }
public _Navigator(Navigator parent, HomePage page, Dispatcher dispatcher) : base(page, FacebookObjectId.Create("[homepage]"), parent) { }
public _Navigator(LoginPage page, Dispatcher dispatcher) : base(page, FacebookObjectId.Create("[Login Page]"), null) { }