Пример #1
0
        private Uri MapProtocolLaunchUri(Uri uri)
        {
            string originalString = uri.OriginalString;
            Dictionary <string, string> parametersAsDict = QueryStringHelper.GetParametersAsDict(originalString);
            string str1 = "/VKClient.Common;component/NewsPage.xaml";
            string str2;

            if (parametersAsDict.ContainsKey("encodedLaunchUri"))
            {
                str2 = HttpUtility.UrlDecode(parametersAsDict["encodedLaunchUri"]);
                if (parametersAsDict.ContainsKey("sourceAppIdentifier"))
                {
                    string str3 = parametersAsDict["sourceAppIdentifier"];
                    if (str2.Contains("/?"))
                    {
                        str2 = str2.Replace("/?", "?");
                    }
                    string oldValue = "vkappconnect://authorize";
                    if (!str2.StartsWith(oldValue))
                    {
                        if (str2.StartsWith("vk://"))
                        {
                            return(new Uri(NavigatorImpl.GetOpenUrlPageStr(str2.Replace("vk://", "https://vk.com/")), UriKind.Relative));
                        }
                        MessageBox.Show("Unsupported protocol: " + str2);
                        str2 = str1;
                    }
                    else if (str2.Contains("RedirectUri=vkc"))
                    {
                        MessageBox.Show("Unsupported redirect uri. Please, use the latest version of WP SDK.");
                        str2 = str1;
                    }
                    else
                    {
                        str2 = str2.Replace(oldValue, "/VKClient.Common;component/SDKAuthPage.xaml") + "&SDKGUID=" + str3.ToLowerInvariant();
                    }
                }
                else if (str2.StartsWith("fb128749580520227://authorize"))
                {
                    if (((UriMapperBase) new FacebookUriMapper()).MapUri(uri).OriginalString.StartsWith("/SuccessfulFacebookLogin.xaml"))
                    {
                        return(new Uri("/VKClient.Common;component/FriendsImportFacebookPage.xaml", UriKind.Relative));
                    }
                }
                else if (str2.StartsWith("com.vk.vkclient:/gmail-oauth/code"))
                {
                    Dictionary <string, string> queryString = CustomUriMapper.ParseQueryString(str2);
                    if (queryString != null && queryString.ContainsKey("code"))
                    {
                        string str3 = queryString["code"];
                        if (!string.IsNullOrEmpty(str3))
                        {
                            return(new Uri(string.Format("/VKClient.Common;component/FriendsImportGmailPage.xaml?code={0}", str3), UriKind.Relative));
                        }
                    }
                }
                else if (str2.StartsWith("com.vk.vkclient://twitter-oauth/callback"))
                {
                    Dictionary <string, string> queryString = CustomUriMapper.ParseQueryString(str2);
                    if (queryString != null && queryString.ContainsKey("oauth_token") && queryString.ContainsKey("oauth_verifier"))
                    {
                        string str3 = queryString["oauth_token"];
                        string str4 = queryString["oauth_verifier"];
                        if (!string.IsNullOrEmpty(str3) && !string.IsNullOrEmpty(str4))
                        {
                            return(new Uri(string.Format("/VKClient.Common;component/FriendsImportTwitterPage.xaml?oauthToken={0}&oauthVerifier={1}", str3, str4), UriKind.Relative));
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Unable to identify source app or uri launch from uri " + originalString);
                str2 = str1;
            }
            return(new Uri(str2, UriKind.Relative));
        }