Exemplo n.º 1
0
        /// <summary>
        /// Parse a URL with a relative path of the form /users/First_Last and try to
        /// retrieve the profile matching that avatar name
        /// </summary>
        /// <param name="requestUrl">URL to parse for an avatar name</param>
        /// <param name="profile">Profile data for the avatar</param>
        /// <returns>True if the parse and lookup were successful, otherwise false</returns>
        bool TryGetProfile(Uri requestUrl, out UserProfileData profile)
        {
            if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/")
            {
                // Parse the avatar name from the path
                string   username = requestUrl.Segments[requestUrl.Segments.Length - 1];
                string[] name     = username.Split('_');

                if (name.Length == 2)
                {
                    profile = m_loginService.GetTheUser(name[0], name[1]);
                    return(profile != null);
                }
            }

            profile = null;
            return(false);
        }