Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        protected Navigator(object content, FacebookObjectId guid, Navigator parent)
        {
            Verify.IsNotNull(content, "content");
            Verify.IsTrue(FacebookObjectId.IsValid(guid), "Invalid guid");
            Content = content;

            Guid = guid;
            if (parent != null)
            {
                Parent = parent;
                Path   = Parent.Path + "/" + Uri.EscapeDataString(Guid.ToString());
            }
            else
            {
                Path = Uri.EscapeDataString(Guid.ToString());
            }
        }
Ejemplo n.º 3
0
        protected override Navigator GetChildNavigatorWithGuid(FacebookObjectId guid)
        {
            Verify.IsTrue(FacebookObjectId.IsValid(guid), "Invalid guid");
            _album.VerifyAccess();

            for (int index = 0; index < _album.Photos.Count; ++index)
            {
                if (_album.Photos[index].PhotoId == guid)
                {
                    var navigator = new PhotoNavigator(_album.Photos[index], this)
                    {
                        ParentIndex = index,
                    };
                    return(navigator);
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
        public static void GoOnline(string sessionKey, string sessionSecret, FacebookObjectId userId)
        {
            Verify.IsNeitherNullNorEmpty(sessionKey, "sessionKey");
            Verify.IsNeitherNullNorEmpty(sessionSecret, "sessionSecret");
            Verify.IsTrue(FacebookObjectId.IsValid(userId), "invalid userId");

            if (FacebookService.IsOnline)
            {
                throw new InvalidOperationException();
            }

            FacebookService.RecoverSession(sessionKey, sessionSecret, userId);

            var handler = GoneOnline;

            if (handler != null)
            {
                handler(FacebookService, new EventArgs());
            }
        }