System.Uri.GetUnescapedParts C# (CSharp) Method

GetUnescapedParts() private method

private GetUnescapedParts ( UriComponents uriParts, UriFormat formatAs ) : string
uriParts UriComponents
formatAs UriFormat
return string
        private string GetUnescapedParts(UriComponents uriParts, UriFormat formatAs)
        {
            // Which Uri parts are not escaped canonically ?
            // Notice that public UriComponents and private Uri.Flags must me in Sync so below code can work
            //
            ushort nonCanonical = (ushort)((ushort)_flags & (ushort)Flags.CannotDisplayCanonical);

            // We keep separate flags for some of path canonicalization facts
            if ((uriParts & UriComponents.Path) != 0)
            {
                if ((_flags & (Flags.ShouldBeCompressed | Flags.FirstSlashAbsent | Flags.BackslashInPath)) != 0)
                {
                    nonCanonical |= (ushort)Flags.PathNotCanonical;
                }
                else if (IsDosPath && _string[_info.Offset.Path + SecuredPathIndex - 1] == '|')
                {
                    // A rare case of c|\
                    nonCanonical |= (ushort)Flags.PathNotCanonical;
                }
            }

            if (((ushort)uriParts & nonCanonical) == 0)
            {
                string ret = GetUriPartsFromUserString(uriParts);
                if ((object)ret != null)
                {
                    return ret;
                }
            }

            return ReCreateParts(uriParts, nonCanonical, formatAs);
        }