System.Security.Util.URLString.SpecialNormalizeUrl C# (CSharp) Method

SpecialNormalizeUrl() private method

private SpecialNormalizeUrl ( ) : URLString
return URLString
        internal URLString SpecialNormalizeUrl()
        {
            // Under WinXP, file protocol urls can be mapped to
            // drives that aren't actually file protocol underneath
            // due to drive mounting.  This code attempts to figure
            // out what a drive is mounted to and create the
            // url is maps to.

            DoDeferredParse();
            if (String.Compare( m_protocol, "file", StringComparison.OrdinalIgnoreCase) != 0)
            {
                return this;
            }
            else
            {
                String localSite = m_localSite.ToString();

                if (localSite.Length == 2 &&
                    (localSite[1] == '|' ||
                     localSite[1] == ':'))
                {
                    String deviceName = _GetDeviceName( localSite );

                    if (deviceName != null)
                    {
                        if (deviceName.IndexOf( "://", StringComparison.Ordinal ) != -1)
                        {
                            URLString u = new URLString( deviceName + "/" + this.m_directory.ToString() );
                            u.DoDeferredParse(); // Presumably the caller of SpecialNormalizeUrl wants a fully parsed URL
                            return u;
                        }
                        else
                        {
                            URLString u = new URLString( "file://" + deviceName + "/" + this.m_directory.ToString() );
                            u.DoDeferredParse();// Presumably the caller of SpecialNormalizeUrl wants a fully parsed URL
                            return u;
                        }
                    }
                    else
                        return this;
                }
                else
                {
                    return this;
                }
            }
        }
                

Usage Example

Example #1
0
        public static bool CompareUrls(URLString url1, URLString url2)
        {
            if (url1 == null && url2 == null)
            {
                return(true);
            }
            if (url1 == null || url2 == null)
            {
                return(false);
            }
            url1.DoDeferredParse();
            url2.DoDeferredParse();
            URLString urlString1 = url1.SpecialNormalizeUrl();
            URLString urlString2 = url2.SpecialNormalizeUrl();

            if (string.Compare(urlString1.m_protocol, urlString2.m_protocol, StringComparison.OrdinalIgnoreCase) != 0)
            {
                return(false);
            }
            if (string.Compare(urlString1.m_protocol, "file", StringComparison.OrdinalIgnoreCase) == 0)
            {
                if (!urlString1.m_localSite.IsSubsetOf(urlString2.m_localSite) || !urlString2.m_localSite.IsSubsetOf(urlString1.m_localSite))
                {
                    return(false);
                }
            }
            else if (string.Compare(urlString1.m_userpass, urlString2.m_userpass, StringComparison.Ordinal) != 0 || !urlString1.m_siteString.IsSubsetOf(urlString2.m_siteString) || (!urlString2.m_siteString.IsSubsetOf(urlString1.m_siteString) || url1.m_port != url2.m_port))
            {
                return(false);
            }
            return(urlString1.m_directory.IsSubsetOf(urlString2.m_directory) && urlString2.m_directory.IsSubsetOf(urlString1.m_directory));
        }
All Usage Examples Of System.Security.Util.URLString::SpecialNormalizeUrl