• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.UriParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.UriParser的典型用法代码示例。如果您正苦于以下问题:C# UriParser类的具体用法?C# UriParser怎么用?C# UriParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UriParser类属于System命名空间,在下文中一共展示了UriParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UriParser

 static UriParser()
 {
     m_Table[HttpUri.SchemeName] = HttpUri;
     HttpsUri = new BuiltInUriParser("https", 0x1bb, HttpUri.m_Flags);
     m_Table[HttpsUri.SchemeName] = HttpsUri;
     FtpUri = new BuiltInUriParser("ftp", 0x15, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
     m_Table[FtpUri.SchemeName] = FtpUri;
     FileUri = new BuiltInUriParser("file", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowDOSPath | UriSyntaxFlags.FileLikeUri | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MustHaveAuthority);
     m_Table[FileUri.SchemeName] = FileUri;
     GopherUri = new BuiltInUriParser("gopher", 70, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
     m_Table[GopherUri.SchemeName] = GopherUri;
     NntpUri = new BuiltInUriParser("nntp", 0x77, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
     m_Table[NntpUri.SchemeName] = NntpUri;
     NewsUri = new BuiltInUriParser("news", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath);
     m_Table[NewsUri.SchemeName] = NewsUri;
     MailToUri = new BuiltInUriParser("mailto", 0x19, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.MailToLikeUri | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo);
     m_Table[MailToUri.SchemeName] = MailToUri;
     UuidUri = new BuiltInUriParser("uuid", -1, NewsUri.m_Flags);
     m_Table[UuidUri.SchemeName] = UuidUri;
     TelnetUri = new BuiltInUriParser("telnet", 0x17, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
     m_Table[TelnetUri.SchemeName] = TelnetUri;
     LdapUri = new BuiltInUriParser("ldap", 0x185, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MayHaveUserInfo | UriSyntaxFlags.MustHaveAuthority);
     m_Table[LdapUri.SchemeName] = LdapUri;
     NetTcpUri = new BuiltInUriParser("net.tcp", 0x328, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MayHavePort | UriSyntaxFlags.MustHaveAuthority);
     m_Table[NetTcpUri.SchemeName] = NetTcpUri;
     NetPipeUri = new BuiltInUriParser("net.pipe", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.PathIsRooted | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHaveQuery | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MustHaveAuthority);
     m_Table[NetPipeUri.SchemeName] = NetPipeUri;
     VsMacrosUri = new BuiltInUriParser("vsmacros", -1, UriSyntaxFlags.AllowIriParsing | UriSyntaxFlags.AllowIdn | UriSyntaxFlags.UnEscapeDotsAndSlashes | UriSyntaxFlags.CanonicalizeAsFilePath | UriSyntaxFlags.CompressPath | UriSyntaxFlags.ConvertPathSlashes | UriSyntaxFlags.AllowDOSPath | UriSyntaxFlags.FileLikeUri | UriSyntaxFlags.AllowAnInternetHost | UriSyntaxFlags.AllowUncHost | UriSyntaxFlags.AllowEmptyHost | UriSyntaxFlags.MayHaveFragment | UriSyntaxFlags.MayHavePath | UriSyntaxFlags.MustHaveAuthority);
     m_Table[VsMacrosUri.SchemeName] = VsMacrosUri;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:UriParser.cs


示例2: CheckAuthorityHelper

        //
        // Checks the syntax of an authority component. It may also get a userInfo if present
        // Returns an error if no/mailformed authority found
        // Does not NOT touch m_Info
        // Returns position of the Path component
        //
        // Must be called in the ctor only
        private unsafe ushort CheckAuthorityHelper(char* pString, ushort idx, ushort length,
            ref ParsingError err, ref Flags flags, UriParser syntax, ref string newHost)
        {
            int end = length;
            char ch;
            int startInput = idx;
            ushort start = idx;
            newHost = null;
            bool justNormalized = false;
            bool iriParsing = (s_IriParsing && IriParsingStatic(syntax)); // perf
            bool hasUnicode = ((flags & Flags.HasUnicode) != 0); // perf
            bool hostNotUnicodeNormalized = ((flags & Flags.HostUnicodeNormalized) == 0); // perf
            UriSyntaxFlags syntaxFlags = syntax.Flags;

            // need to build new Iri'zed string
            if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
            {
                newHost = _originalUnicodeString.Substring(0, startInput);
            }

            //Special case is an empty authority
            if (idx == length || ((ch = pString[idx]) == '/' || (ch == '\\' && StaticIsFile(syntax)) || ch == '#' || ch == '?'))
            {
                if (syntax.InFact(UriSyntaxFlags.AllowEmptyHost))
                {
                    flags &= ~Flags.UncPath;    //UNC cannot have an empty hostname
                    if (StaticInFact(flags, Flags.ImplicitFile))
                        err = ParsingError.BadHostName;
                    else
                        flags |= Flags.BasicHostType;
                }
                else
                    err = ParsingError.BadHostName;

                if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
                {
                    flags |= Flags.HostUnicodeNormalized;// no host
                }

                return idx;
            }

            string userInfoString = null;
            // Attempt to parse user info first

            if ((syntaxFlags & UriSyntaxFlags.MayHaveUserInfo) != 0)
            {
                for (; start < end; ++start)
                {
                    if (start == end - 1 || pString[start] == '?' || pString[start] == '#' || pString[start] == '\\' ||
                        pString[start] == '/')
                    {
                        start = idx;
                        break;
                    }
                    else if (pString[start] == '@')
                    {
                        flags |= Flags.HasUserInfo;

                        // Iri'ze userinfo
                        if (iriParsing || (s_IdnScope != UriIdnScope.None))
                        {
                            if (iriParsing && hasUnicode && hostNotUnicodeNormalized)
                            {
                                // Normalize user info
                                userInfoString = IriHelper.EscapeUnescapeIri(pString, startInput, start + 1, UriComponents.UserInfo);
                                newHost += userInfoString;
                            }
                            else
                            {
                                userInfoString = new string(pString, startInput, start - startInput + 1);
                            }
                        }
                        ++start;
                        ch = pString[start];
                        break;
                    }
                }
            }

            // DNS name only optimization
            // Fo an overridden parsing the optimization is suppressed since hostname can be changed to anything
            bool dnsNotCanonical = ((syntaxFlags & UriSyntaxFlags.SimpleUserSyntax) == 0);

            if (ch == '[' && syntax.InFact(UriSyntaxFlags.AllowIPv6Host)
                && IPv6AddressHelper.IsValid(pString, (int)start + 1, ref end))
            {
                flags |= Flags.IPv6HostType;

                _iriParsing = (s_IriParsing && IriParsingStatic(syntax));

                if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
                {
//.........这里部分代码省略.........
开发者ID:shmao,项目名称:corefx,代码行数:101,代码来源:Uri.cs


示例3: UnescapeString

 //
 // This method will assume that any good Escaped Sequence will be unescaped in the output
 // - Assumes Dest.Length - detPosition >= end-start
 // - UnescapeLevel controls various modes of opearion
 // - Any "bad" escape sequence will remain as is or '%' will be escaped.
 // - destPosition tells the starting index in dest for placing the result.
 //   On return destPosition tells the last character + 1 postion in the "dest" array.
 // - The control chars and chars passed in rsdvX parameters may be re-escaped depending on UnescapeLevel
 // - It is a RARE case when Unescape actually needs escaping some characteres mentioned above.
 //   For this reason it returns a char[] that is usually the same ref as the input "dest" value.
 //
 internal unsafe static char[] UnescapeString(string input, int start, int end, char[] dest, 
     ref int destPosition, char rsvd1, char rsvd2, char rsvd3, UnescapeMode unescapeMode, UriParser syntax, 
     bool isQuery)
 {
     fixed (char *pStr = input)
     {
         return UnescapeString(pStr, start, end, dest, ref destPosition, rsvd1, rsvd2, rsvd3, unescapeMode, 
             syntax, isQuery);
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:21,代码来源:UriHelper.cs


示例4: Register

        //
        // Static Registration methods
        //
        //
        // Registers a custom Uri parser based on a scheme string
        //
        public static void Register(UriParser uriParser, string schemeName, int defaultPort)
        {
            if (uriParser == null)
                throw new ArgumentNullException("uriParser");
 
            if (schemeName == null)
                throw new ArgumentNullException("schemeName");
 
            if (schemeName.Length == 1)
                throw new ArgumentOutOfRangeException("schemeName");
 
            if (!Uri.CheckSchemeName(schemeName))
                throw new ArgumentOutOfRangeException("schemeName");
 
            if ((defaultPort >= 0xFFFF || defaultPort < 0) && defaultPort != -1)
                throw new ArgumentOutOfRangeException("defaultPort");
 
            schemeName = schemeName.ToLower();
            FetchSyntax(uriParser, schemeName, defaultPort);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:26,代码来源:UriScheme.cs


示例5: CheckAuthorityHelperHandleDnsIri

 private unsafe void CheckAuthorityHelperHandleDnsIri(char* pString, ushort start, int end, int startInput, bool iriParsing, bool hasUnicode, UriParser syntax, string userInfoString, ref Flags flags, ref bool justNormalized, ref string newHost, ref ParsingError err)
 {
     flags |= Flags.DnsHostType;
     if ((s_IdnScope == 1) && this.IsIntranet(new string(pString, 0, end)))
     {
         flags |= Flags.HostNotParsed | Flags.IntranetUri;
     }
     if (this.AllowIdnStatic(syntax, flags))
     {
         bool allAscii = true;
         bool atLeastOneValidIdn = false;
         string idnHost = DomainNameHelper.IdnEquivalent(pString, start, end, ref allAscii, ref atLeastOneValidIdn);
         string str2 = DomainNameHelper.UnicodeEquivalent(idnHost, pString, start, end);
         if (!allAscii)
         {
             flags |= Flags.HostNotParsed | Flags.UnicodeHost;
         }
         if (atLeastOneValidIdn)
         {
             flags |= Flags.HostNotParsed | Flags.IdnHost;
         }
         if ((allAscii && atLeastOneValidIdn) && StaticNotAny(flags, Flags.HasUnicode))
         {
             this.m_originalUnicodeString = this.m_String;
             newHost = this.m_originalUnicodeString.Substring(0, startInput) + (StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
             justNormalized = true;
         }
         else if (!iriParsing && (StaticInFact(flags, Flags.HostNotParsed | Flags.UnicodeHost) || StaticInFact(flags, Flags.HostNotParsed | Flags.IdnHost)))
         {
             this.m_originalUnicodeString = this.m_String;
             newHost = this.m_originalUnicodeString.Substring(0, startInput) + (StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
             justNormalized = true;
         }
         if (!allAscii || atLeastOneValidIdn)
         {
             this.m_DnsSafeHost = idnHost;
             newHost = newHost + str2;
             justNormalized = true;
         }
         else if ((allAscii && !atLeastOneValidIdn) && (iriParsing && hasUnicode))
         {
             newHost = newHost + str2;
             justNormalized = true;
         }
     }
     else if (hasUnicode)
     {
         string str3 = StripBidiControlCharacter(pString, start, end - start);
         try
         {
             newHost = newHost + ((str3 != null) ? str3.Normalize(NormalizationForm.FormC) : null);
         }
         catch (ArgumentException)
         {
             err = ParsingError.BadHostName;
         }
         justNormalized = true;
     }
     flags |= Flags.HostNotParsed | Flags.HostUnicodeNormalized;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:60,代码来源:Uri.cs


示例6: UnescapeString

 private static unsafe char[] UnescapeString(string input, int start, int end, char[] dest, ref int destPosition, char rsvd1, char rsvd2, char rsvd3, UnescapeMode unescapeMode, UriParser syntax, bool isQuery, bool readOnlyConfig)
 {
     fixed (char* str = ((char*) input))
     {
         char* pStr = str;
         return UnescapeString(pStr, start, end, dest, ref destPosition, rsvd1, rsvd2, rsvd3, unescapeMode, syntax, isQuery, readOnlyConfig);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:Uri.cs


示例7: StaticIsFile

 private static bool StaticIsFile(UriParser syntax)
 {
     return syntax.InFact(UriSyntaxFlags.FileLikeUri);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:Uri.cs


示例8: ParseScheme

 private static unsafe ParsingError ParseScheme(string uriString, ref Flags flags, ref UriParser syntax)
 {
     int length = uriString.Length;
     if (length == 0)
     {
         return ParsingError.EmptyUriString;
     }
     if (length >= 0xfff0)
     {
         return ParsingError.SizeLimit;
     }
     fixed (char* str = ((char*) uriString))
     {
         char* chPtr = str;
         ParsingError none = ParsingError.None;
         ushort num2 = ParseSchemeCheckImplicitFile(chPtr, (ushort) length, ref none, ref flags, ref syntax);
         if (none != ParsingError.None)
         {
             return none;
         }
         flags |= (Flags) num2;
     }
     return ParsingError.None;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:Uri.cs


示例9: Uri

 // Should never be used except by the below method
 private Uri(Flags flags, UriParser uriParser, string uri)
 {
     _flags = flags;
     _syntax = uriParser;
     _string = uri;
 }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:7,代码来源:UriExt.cs


示例10: UriParser

        static UriParser()
        {
            s_table = new LowLevelDictionary<string, UriParser>(c_InitialTableSize);
            s_tempTable = new LowLevelDictionary<string, UriParser>(c_InitialTableSize);

            //Now we will call for the instance constructors that will interrupt this static one.

            // Below we simulate calls into FetchSyntax() but avoid using lock() and other things redundant for a .cctor

            HttpUri = new BuiltInUriParser("http", 80, HttpSyntaxFlags);
            s_table[HttpUri.SchemeName] = HttpUri;                   //HTTP

            HttpsUri = new BuiltInUriParser("https", 443, HttpUri._flags);
            s_table[HttpsUri.SchemeName] = HttpsUri;                  //HTTPS cloned from HTTP

            WsUri = new BuiltInUriParser("ws", 80, HttpSyntaxFlags);
            s_table[WsUri.SchemeName] = WsUri;                   // WebSockets

            WssUri = new BuiltInUriParser("wss", 443, HttpSyntaxFlags);
            s_table[WssUri.SchemeName] = WssUri;                  // Secure WebSockets

            FtpUri = new BuiltInUriParser("ftp", 21, FtpSyntaxFlags);
            s_table[FtpUri.SchemeName] = FtpUri;                    //FTP

            FileUri = new BuiltInUriParser("file", NoDefaultPort, s_fileSyntaxFlags);
            s_table[FileUri.SchemeName] = FileUri;                   //FILE

            GopherUri = new BuiltInUriParser("gopher", 70, GopherSyntaxFlags);
            s_table[GopherUri.SchemeName] = GopherUri;                 //GOPHER

            NntpUri = new BuiltInUriParser("nntp", 119, NntpSyntaxFlags);
            s_table[NntpUri.SchemeName] = NntpUri;                   //NNTP

            NewsUri = new BuiltInUriParser("news", NoDefaultPort, NewsSyntaxFlags);
            s_table[NewsUri.SchemeName] = NewsUri;                   //NEWS

            MailToUri = new BuiltInUriParser("mailto", 25, MailtoSyntaxFlags);
            s_table[MailToUri.SchemeName] = MailToUri;                 //MAILTO

            UuidUri = new BuiltInUriParser("uuid", NoDefaultPort, NewsUri._flags);
            s_table[UuidUri.SchemeName] = UuidUri;                   //UUID cloned from NEWS

            TelnetUri = new BuiltInUriParser("telnet", 23, TelnetSyntaxFlags);
            s_table[TelnetUri.SchemeName] = TelnetUri;                 //TELNET

            LdapUri = new BuiltInUriParser("ldap", 389, LdapSyntaxFlags);
            s_table[LdapUri.SchemeName] = LdapUri;                   //LDAP

            NetTcpUri = new BuiltInUriParser("net.tcp", 808, NetTcpSyntaxFlags);
            s_table[NetTcpUri.SchemeName] = NetTcpUri;

            NetPipeUri = new BuiltInUriParser("net.pipe", NoDefaultPort, NetPipeSyntaxFlags);
            s_table[NetPipeUri.SchemeName] = NetPipeUri;

            VsMacrosUri = new BuiltInUriParser("vsmacros", NoDefaultPort, VsmacrosSyntaxFlags);
            s_table[VsMacrosUri.SchemeName] = VsMacrosUri;               //VSMACROS
        }
开发者ID:SGuyGe,项目名称:corefx,代码行数:57,代码来源:UriSyntax.cs


示例11: Compress

        //
        // This will compress any "\" "/../" "/./" "///" "/..../" /XXX.../, etc found in the input
        //
        // The passed syntax controls whether to use aggressive compression or the one specified in RFC 2396
        //
        private static char[] Compress(char[] dest, ushort start, ref int destLength, UriParser syntax)
        {
            ushort slashCount = 0;
            ushort lastSlash = 0;
            ushort dotCount = 0;
            ushort removeSegments = 0;

            unchecked
            {
                //ushort i == -1 and start == -1 overflow is ok here
                ushort i = (ushort)((ushort)destLength - (ushort)1);
                start = (ushort)(start - 1);

                for (; i != start; --i)
                {
                    char ch = dest[i];
                    if (ch == '\\' && syntax.InFact(UriSyntaxFlags.ConvertPathSlashes))
                    {
                        dest[i] = ch = '/';
                    }

                    //
                    // compress multiple '/' for file URI
                    //
                    if (ch == '/')
                    {
                        ++slashCount;
                    }
                    else
                    {
                        if (slashCount > 1)
                        {
                            // else preserve repeated slashes
                            lastSlash = (ushort)(i + 1);
                        }
                        slashCount = 0;
                    }

                    if (ch == '.')
                    {
                        ++dotCount;
                        continue;
                    }
                    else if (dotCount != 0)
                    {
                        bool skipSegment = syntax.NotAny(UriSyntaxFlags.CanonicalizeAsFilePath)
                            && (dotCount > 2 || ch != '/' || i == start);

                        //
                        // Cases:
                        // /./                  = remove this segment 
                        // /../                 = remove this segment, mark next for removal
                        // /....x               = DO NOT TOUCH, leave as is
                        // x.../                = DO NOT TOUCH, leave as is, except for V2 legacy mode
                        //
                        if (!skipSegment && ch == '/')
                        {
                            if ((lastSlash == i + dotCount + 1 // "/..../"
                                    || (lastSlash == 0 && i + dotCount + 1 == destLength)) // "/..."
                                && (dotCount <= 2))
                            {
                                //
                                //  /./ or /.<eos> or /../ or /..<eos>
                                //
                                // just reusing a variable slot we perform //dest.Remove(i+1, dotCount + (lastSlash==0?0:1));
                                lastSlash = (ushort)(i + 1 + dotCount + (lastSlash == 0 ? 0 : 1));
                                Buffer.BlockCopy(dest, lastSlash << 1, dest, (i + 1) << 1, (destLength - lastSlash) << 1);
                                destLength -= (lastSlash - i - 1);

                                lastSlash = i;
                                if (dotCount == 2)
                                {
                                    //
                                    // We have 2 dots in between like /../ or /..<eos>,
                                    // Mark next segment for removal and remove this /../ or /..
                                    //
                                    ++removeSegments;
                                }
                                dotCount = 0;
                                continue;
                            }
                        }
                        // .NET 4.5 no longer removes trailing dots in a path segment x.../  or  x...<eos>
                        dotCount = 0;

                        //
                        // Here all other cases go such as
                        // x.[..]y or /.[..]x or (/x.[...][/] && removeSegments !=0)
                    }

                    //
                    // Now we may want to remove a segment because of previous /../
                    //
                    if (ch == '/')
                    {
//.........这里部分代码省略.........
开发者ID:shmao,项目名称:corefx,代码行数:101,代码来源:Uri.cs


示例12: CheckAuthorityHelperHandleAnyHostIri

        private unsafe void CheckAuthorityHelperHandleAnyHostIri(char* pString, int startInput, int end,
                                            bool iriParsing, bool hasUnicode, UriParser syntax,
                                            ref Flags flags, ref string newHost, ref ParsingError err)
        {
            if (StaticNotAny(flags, Flags.HostUnicodeNormalized) && (AllowIdnStatic(syntax, flags) ||
                (iriParsing && hasUnicode)))
            {
                // Normalize any other host or do idn
                string user = new string(pString, startInput, end - startInput);

                if (AllowIdnStatic(syntax, flags))
                {
                    bool allAscii = true;
                    bool atLeastOneIdn = false;

                    string UniEquvlt = DomainNameHelper.UnicodeEquivalent(pString, startInput, end, ref allAscii,
                        ref atLeastOneIdn);

                    if (((allAscii && atLeastOneIdn) || !allAscii) && !(iriParsing && hasUnicode))
                    {
                        // original string location changed lazily
                        _originalUnicodeString = _string;
                        newHost = _originalUnicodeString.Substring(0, startInput);
                        flags |= Flags.HasUnicode;
                    }
                    if (atLeastOneIdn || !allAscii)
                    {
                        newHost += UniEquvlt;
                        string bidiStrippedHost = null;
                        _dnsSafeHost = DomainNameHelper.IdnEquivalent(pString, startInput, end, ref allAscii,
                            ref bidiStrippedHost);
                        if (atLeastOneIdn)
                            flags |= Flags.IdnHost;
                        if (!allAscii)
                            flags |= Flags.UnicodeHost;
                    }
                    else if (iriParsing && hasUnicode)
                    {
                        newHost += user;
                    }
                }
                else
                {
                    try
                    {
                        newHost += user.Normalize(NormalizationForm.FormC);
                    }
                    catch (ArgumentException)
                    {
                        err = ParsingError.BadHostName;
                    }
                }

                flags |= Flags.HostUnicodeNormalized;
            }
        }
开发者ID:shmao,项目名称:corefx,代码行数:56,代码来源:Uri.cs


示例13: CheckAuthorityHelperHandleDnsIri

        private unsafe void CheckAuthorityHelperHandleDnsIri(char* pString, ushort start, int end, int startInput,
            bool iriParsing, bool hasUnicode, UriParser syntax, string userInfoString, ref Flags flags,
            ref bool justNormalized, ref string newHost, ref ParsingError err)
        {
            // comes here only if host has unicode chars and iri is on or idn is allowed

            flags |= Flags.DnsHostType;

            // check if intranet
            //
            if ((s_IdnScope == UriIdnScope.AllExceptIntranet) && IsIntranet(new string(pString, 0, end)))
            {
                flags |= Flags.IntranetUri;
            }

            if (AllowIdnStatic(syntax, flags))
            {
                bool allAscii = true;
                bool atLeastOneIdn = false;

                string idnValue = DomainNameHelper.IdnEquivalent(pString, start, end, ref allAscii, ref atLeastOneIdn);
                string UniEquvlt = DomainNameHelper.UnicodeEquivalent(idnValue, pString, start, end);

                if (!allAscii)
                    flags |= Flags.UnicodeHost; // we have a unicode host

                if (atLeastOneIdn)
                    flags |= Flags.IdnHost;   // we have at least one valid idn label

                if (allAscii && atLeastOneIdn && StaticNotAny(flags, Flags.HasUnicode))
                {
                    // original string location changed lazily
                    _originalUnicodeString = _string;
                    newHost = _originalUnicodeString.Substring(0, startInput) +
                        (StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
                    justNormalized = true;
                }
                else if (!iriParsing && (StaticInFact(flags, Flags.UnicodeHost) || StaticInFact(flags, Flags.IdnHost)))
                {
                    // original string location changed lazily
                    _originalUnicodeString = _string;
                    newHost = _originalUnicodeString.Substring(0, startInput) +
                        (StaticInFact(flags, Flags.HasUserInfo) ? userInfoString : null);
                    justNormalized = true;
                }

                if (!(allAscii && !atLeastOneIdn))
                {
                    _dnsSafeHost = idnValue;
                    newHost += UniEquvlt;
                    justNormalized = true;
                }
                else if (allAscii && !atLeastOneIdn && iriParsing && hasUnicode)
                {
                    newHost += UniEquvlt;
                    justNormalized = true;
                }
            }
            else
            {
                if (hasUnicode)
                {
                    string temp = UriHelper.StripBidiControlCharacter(pString, start, end - start);
                    try
                    {
                        newHost += ((temp != null) ? temp.Normalize(NormalizationForm.FormC) : null);
                    }
                    catch (ArgumentException)
                    {
                        err = ParsingError.BadHostName;
                    }
                    justNormalized = true;
                }
            }
            flags |= Flags.HostUnicodeNormalized;
        }
开发者ID:shmao,项目名称:corefx,代码行数:76,代码来源:Uri.cs


示例14: IriParsingStatic

 private static bool IriParsingStatic(UriParser syntax)
 {
     if (!s_IriParsing)
     {
         return false;
     }
     return (((syntax != null) && syntax.InFact(UriSyntaxFlags.AllowIriParsing)) || (syntax == null));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:Uri.cs


示例15: CheckSchemeSyntax

 private static unsafe ParsingError CheckSchemeSyntax(char* ptr, ushort length, ref UriParser syntax)
 {
     char ch = ptr[0];
     if ((ch < 'a') || (ch > 'z'))
     {
         if ((ch < 'A') || (ch > 'Z'))
         {
             return ParsingError.BadScheme;
         }
         ptr[0] = (char) (ch | ' ');
     }
     for (ushort i = 1; i < length; i = (ushort) (i + 1))
     {
         char ch2 = ptr[i];
         if ((ch2 < 'a') || (ch2 > 'z'))
         {
             if ((ch2 >= 'A') && (ch2 <= 'Z'))
             {
                 ptr[i] = (char) (ch2 | ' ');
             }
             else if (((ch2 < '0') || (ch2 > '9')) && (((ch2 != '+') && (ch2 != '-')) && (ch2 != '.')))
             {
                 return ParsingError.BadScheme;
             }
         }
     }
     string lwrCaseScheme = new string(ptr, 0, length);
     syntax = UriParser.FindOrFetchAsUnknownV1Syntax(lwrCaseScheme);
     return ParsingError.None;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:Uri.cs


示例16: ParseSchemeCheckImplicitFile

 private static unsafe ushort ParseSchemeCheckImplicitFile(char* uriString, ushort length, ref ParsingError err, ref Flags flags, ref UriParser syntax)
 {
     ushort index = 0;
     while ((index < length) && IsLWS(uriString[index]))
     {
         index = (ushort) (index + 1);
     }
     ushort num2 = index;
     while ((num2 < length) && (uriString[num2] != ':'))
     {
         num2 = (ushort) (num2 + 1);
     }
     if (((IntPtr.Size != 4) || (num2 == length)) || ((num2 < (index + 3)) || !CheckKnownSchemes((long*) (uriString + index), (ushort) (num2 - index), ref syntax)))
     {
         char ch;
         if (((index + 2) >= length) || (num2 == index))
         {
             err = ParsingError.BadFormat;
             return 0;
         }
         if (((ch = uriString[index + 1]) == ':') || (ch == '|'))
         {
             if (IsAsciiLetter(uriString[index]))
             {
                 if (((ch = uriString[index + 2]) == '\\') || (ch == '/'))
                 {
                     flags |= Flags.AuthorityFound | Flags.DosPath | Flags.ImplicitFile;
                     syntax = UriParser.FileUri;
                     return index;
                 }
                 err = ParsingError.MustRootedPath;
                 return 0;
             }
             if (ch == ':')
             {
                 err = ParsingError.BadScheme;
             }
             else
             {
                 err = ParsingError.BadFormat;
             }
             return 0;
         }
         if (((ch = uriString[index]) == '/') || (ch == '\\'))
         {
             if (((ch = uriString[index + 1]) == '\\') || (ch == '/'))
             {
                 flags |= Flags.AuthorityFound | Flags.ImplicitFile | Flags.UncPath;
                 syntax = UriParser.FileUri;
                 index = (ushort) (index + 2);
                 while ((index < length) && (((ch = uriString[index]) == '/') || (ch == '\\')))
                 {
                     index = (ushort) (index + 1);
                 }
                 return index;
             }
             err = ParsingError.BadFormat;
             return 0;
         }
         if (num2 == length)
         {
             err = ParsingError.BadFormat;
             return 0;
         }
         if ((num2 - index) > 0x400)
         {
             err = ParsingError.SchemeLimit;
             return 0;
         }
         char* ptr = (char*) stackalloc byte[(((IntPtr) (num2 - index)) * 2)];
         length = 0;
         while (index < num2)
         {
             length = (ushort) (length + 1);
             ptr[length] = uriString[index];
             index = (ushort) (index + 1);
         }
         err = CheckSchemeSyntax(ptr, length, ref syntax);
         if (err != ParsingError.None)
         {
             return 0;
         }
     }
     return (ushort) (num2 + 1);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:85,代码来源:Uri.cs


示例17: CheckAuthorityHelperHandleAnyHostIri

 private unsafe void CheckAuthorityHelperHandleAnyHostIri(char* pString, int startInput, int end, bool iriParsing, bool hasUnicode, UriParser syntax, ref Flags flags, ref string newHost, ref ParsingError err)
 {
     if (StaticNotAny(flags, Flags.HostNotParsed | Flags.HostUnicodeNormalized) && (this.AllowIdnStatic(syntax, flags) || (iriParsing && hasUnicode)))
     {
         string str = new string(pString, startInput, end - startInput);
         if (this.AllowIdnStatic(syntax, flags))
         {
             bool allAscii = true;
             bool atLeastOneValidIdn = false;
             string str2 = DomainNameHelper.UnicodeEquivalent(pString, startInput, end, ref allAscii, ref atLeastOneValidIdn);
             if (((allAscii && atLeastOneValidIdn) || !allAscii) && (!iriParsing || !hasUnicode))
             {
                 this.m_originalUnicodeString = this.m_String;
                 newHost = this.m_originalUnicodeString.Substring(0, startInput);
                 flags |= Flags.HasUnicode;
             }
             if (atLeastOneValidIdn || !allAscii)
             {
                 newHost = newHost + str2;
                 string bidiStrippedHost = null;
                 this.m_DnsSafeHost = DomainNameHelper.IdnEquivalent(pString, startInput, end, ref allAscii, ref bidiStrippedHost);
                 if (atLeastOneValidIdn)
                 {
                     flags |= Flags.HostNotParsed | Flags.IdnHost;
                 }
                 if (!allAscii)
                 {
                     flags |= Flags.HostNotParsed | Flags.UnicodeHost;
                 }
             }
             else if (iriParsing && hasUnicode)
             {
                 newHost = newHost + str;
             }
         }
         else
         {
             try
             {
                 newHost = newHost + str.Normalize(NormalizationForm.FormC);
             }
             catch (ArgumentException)
             {
                 err = ParsingError.BadHostName;
             }
         }
         flags |= Flags.HostNotParsed | Flags.HostUnicodeNormalized;
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:49,代码来源:Uri.cs


示例18: Compress

 private static char[] Compress(char[] dest, ushort start, ref int destLength, UriParser syntax)
 {
     ushort num = 0;
     ushort num2 = 0;
     ushort num3 = 0;
     ushort num4 = 0;
     ushort index = (ushort) (((ushort) destLength) - 1);
     start = (ushort) (start - 1);
     while (index != start)
     {
         char ch = dest[index];
         if ((ch == '\\') && syntax.InFact(UriSyntaxFlags.ConvertPathSlashes))
         {
             dest[index] = ch = '/';
         }
         if (ch == '/')
         {
             num = (ushort) (num + 1);
         }
         else
         {
             if (num > 1)
             {
                 num2 = (ushort) (index + 1);
             }
             num = 0;
         }
         if (ch == '.')
         {
             num3 = (ushort) (num3 + 1);
             goto Label_017F;
         }
         if (num3 == 0)
         {
             goto Label_0148;
         }
         bool flag = syntax.NotAny(UriSyntaxFlags.CanonicalizeAsFilePath) && (((num3 > 2) || (ch != '/')) || (index == start));
         if (!flag && (ch == '/'))
         {
             if ((num2 != ((index + num3) + 1)) && ((num2 != 0) || (((index + num3) + 1) != destLength)))
             {
                 goto Label_0146;
             }
             num2 = (ushort) (((index + 1) + num3) + ((num2 == 0) ? 0 : 1));
             Buffer.BlockCopy(dest, num2 << 1, dest, (index + 1) << 1, (destLength - num2) << 1);
             destLength -= (num2 - index) - 1;
             num2 = index;
             if (num3 == 2)
             {
                 num4 = (ushort) (num4 + 1);
             }
             num3 = 0;
             goto Label_017F;
         }
         if ((!flag && (num4 == 0)) && ((num2 == ((index + num3) + 1)) || ((num2 == 0) && (((index + num3) + 1) == destLength))))
         {
             num3 = (ushort) ((index + 1) + num3);
             Buffer.BlockCopy(dest, num3 << 1, dest, (index + 1) << 1, (destLength - num3) << 1);
             destLength -= (num3 - index) - 1;
             num2 = 0;
             num3 = 0;
             goto Label_017F;
         }
     Label_0146:
         num3 = 0;
     Label_0148:
         if (ch == '/')
         {
             if (num4 != 0)
             {
                 num4 = (ushort) (num4 - 1);
                 num2 = (ushort) (num2 + 1);
                 Buffer.BlockCopy(dest, num2 << 1, dest, (index + 1) << 1, (destLength - num2) << 1);
                 destLength -= (num2 - index) - 1;
             }
             num2 = index;
         }
     Label_017F:
         index = (ushort) (index - 1);
     }
     start = (ushort) (start + 1);
     if (((((ushort) destLength) > start) && syntax.InFact(UriSyntaxFlags.CanonicalizeAsFilePath)) && (num <= 1))
     {
         if ((num4 != 0) && (dest[start] != '/'))
         {
             num2 = (ushort) (num2 + 1);
             Buffer.BlockCopy(dest, num2 << 1, dest, start << 1, (destLength - num2) << 1);
             destLe 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.UriTemplate类代码示例发布时间:2022-05-26
下一篇:
C# System.UriFormatException类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap