WindowsAzure.Acs.Oauth2.Client.WinRT.Protocol.OAuthMessageSerializer.GetBaseUrl C# (CSharp) Method

GetBaseUrl() private static method

private static GetBaseUrl ( Uri uri ) : Uri
uri System.Uri
return System.Uri
        private static Uri GetBaseUrl(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            string tempUri = uri.AbsoluteUri;
            int index = tempUri.IndexOf("?", 0, System.StringComparison.Ordinal);
            if (index > -1)
            {
                tempUri = tempUri.Substring(0, index);
            }
            return new Uri(tempUri);
        }
    }

Usage Example

        public virtual OAuthMessage Read(string httpMethod, string httpContentType, Uri requestUri, System.IO.Stream incomingStream)
        {
            if (string.IsNullOrEmpty(httpMethod))
            {
                throw new ArgumentOutOfRangeException("httpMethod");
            }
            if (requestUri == null)
            {
                throw new ArgumentNullException("requestUri");
            }
            if (incomingStream == null)
            {
                throw new ArgumentNullException("incomingStream");
            }

            Dictionary <string, string> oAuthParameters = new Dictionary <string, string>();

            if (httpMethod == "POST")
            {
                if (httpContentType.Contains("application/x-www-form-urlencoded"))
                {
                    oAuthParameters = this.ReadFormEncodedParameters(incomingStream);
                }
                else
                {
                    if (!httpContentType.Contains("application/json"))
                    {
                        throw new OAuthMessageSerializationException(string.Format(Resources.ID3721, httpMethod, httpContentType));
                    }
                    oAuthParameters = this.ReadJsonEncodedParameters(incomingStream);
                }
            }
            else
            {
                if (!(httpMethod == "GET"))
                {
                    throw new OAuthMessageSerializationException(string.Format(Resources.ID3722, httpMethod));
                }
                oAuthParameters = HttpQueryStringParser.Parse(requestUri.Query);
            }
            return(this.CreateTypedOAuthMessageFromParameters(OAuthMessageSerializer.GetBaseUrl(requestUri), oAuthParameters));
        }