当前位置: 首页>>代码示例>>C#>>正文


C# UriParser.NotAny方法代码示例

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


在下文中一共展示了UriParser.NotAny方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckAuthorityHelper

 private unsafe ushort CheckAuthorityHelper(char* pString, ushort idx, ushort length, ref ParsingError err, ref Flags flags, UriParser syntax, ref string newHost)
 {
     char ch;
     int end = length;
     int num2 = idx;
     ushort index = idx;
     newHost = null;
     bool justNormalized = false;
     bool iriParsing = s_IriParsing && IriParsingStatic(syntax);
     bool hasUnicode = (flags & Flags.HasUnicode) != Flags.HostNotParsed;
     bool flag4 = (flags & (Flags.HostNotParsed | Flags.HostUnicodeNormalized)) == Flags.HostNotParsed;
     UriSyntaxFlags flags2 = syntax.Flags;
     if ((hasUnicode && iriParsing) && flag4)
     {
         newHost = this.m_originalUnicodeString.Substring(0, num2);
     }
     if ((((idx == length) || ((ch = pString[idx]) == '/')) || ((ch == '\\') && StaticIsFile(syntax))) || ((ch == '#') || (ch == '?')))
     {
         if (syntax.InFact(UriSyntaxFlags.AllowEmptyHost))
         {
             flags &= ~(Flags.HostNotParsed | Flags.UncPath);
             if (StaticInFact(flags, Flags.HostNotParsed | Flags.ImplicitFile))
             {
                 err = ParsingError.BadHostName;
             }
             else
             {
                 flags |= Flags.BasicHostType;
             }
         }
         else
         {
             err = ParsingError.BadHostName;
         }
         if ((hasUnicode && iriParsing) && flag4)
         {
             flags |= Flags.HostNotParsed | Flags.HostUnicodeNormalized;
         }
         return idx;
     }
     string userInfoString = null;
     if ((flags2 & UriSyntaxFlags.MayHaveUserInfo) != UriSyntaxFlags.None)
     {
         while (index < end)
         {
             if (((index == (end - 1)) || (pString[index] == '?')) || (((pString[index] == '#') || (pString[index] == '\\')) || (pString[index] == '/')))
             {
                 index = idx;
                 break;
             }
             if (pString[index] == '@')
             {
                 flags |= Flags.HasUserInfo;
                 if (iriParsing || (s_IdnScope != null))
                 {
                     if ((iriParsing && hasUnicode) && flag4)
                     {
                         userInfoString = this.EscapeUnescapeIri(pString, num2, index + 1, UriComponents.UserInfo);
                         try
                         {
                             userInfoString = userInfoString.Normalize(NormalizationForm.FormC);
                         }
                         catch (ArgumentException)
                         {
                             err = ParsingError.BadFormat;
                             return idx;
                         }
                         newHost = newHost + userInfoString;
                     }
                     else
                     {
                         userInfoString = new string(pString, num2, (index - num2) + 1);
                     }
                 }
                 index = (ushort) (index + 1);
                 ch = pString[index];
                 break;
             }
             index = (ushort) (index + 1);
         }
     }
     bool notCanonical = (flags2 & UriSyntaxFlags.SimpleUserSyntax) == UriSyntaxFlags.None;
     if (((ch == '[') && syntax.InFact(UriSyntaxFlags.AllowIPv6Host)) && IPv6AddressHelper.IsValid(pString, index + 1, ref end))
     {
         flags |= Flags.HostNotParsed | Flags.IPv6HostType;
         if (!s_ConfigInitialized)
         {
             InitializeUriConfig();
             this.m_iriParsing = s_IriParsing && IriParsingStatic(syntax);
         }
         if ((hasUnicode && iriParsing) && flag4)
         {
             newHost = newHost + new string(pString, index, end - index);
             flags |= Flags.HostNotParsed | Flags.HostUnicodeNormalized;
             justNormalized = true;
         }
     }
     else if (((ch <= '9') && (ch >= '0')) && (syntax.InFact(UriSyntaxFlags.AllowIPv4Host) && IPv4AddressHelper.IsValid(pString, index, ref end, false, StaticNotAny(flags, Flags.HostNotParsed | Flags.ImplicitFile))))
     {
         flags |= Flags.HostNotParsed | Flags.IPv4HostType;
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:Uri.cs

示例2: 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

示例3: 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);
             destLength -= num2;
             return dest;
         }
         if ((num3 != 0) && ((num2 == (num3 + 1)) || ((num2 == 0) && ((num3 + 1) == destLength))))
         {
             num3 = (ushort) (num3 + ((num2 == 0) ? 0 : 1));
             Buffer.BlockCopy(dest, num3 << 1, dest, start << 1, (destLength - num3) << 1);
             destLength -= num3;
         }
     }
     return dest;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:99,代码来源:Uri.cs

示例4: CheckAuthorityHelper


//.........这里部分代码省略.........
                                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)
                {
                    newHost += new string(pString, start, end - start);
                    flags |= Flags.HostUnicodeNormalized;
                    justNormalized = true;
                }
            }
            else if (ch <= '9' && ch >= '0' && syntax.InFact(UriSyntaxFlags.AllowIPv4Host) &&
                IPv4AddressHelper.IsValid(pString, (int)start, ref end, false, StaticNotAny(flags, Flags.ImplicitFile), syntax.InFact(UriSyntaxFlags.V1_UnknownUri)))
            {
                flags |= Flags.IPv4HostType;

                if (hasUnicode && iriParsing && hostNotUnicodeNormalized)
                {
                    newHost += new string(pString, start, end - start);
                    flags |= Flags.HostUnicodeNormalized;
                    justNormalized = true;
                }
            }
            else if (((syntaxFlags & UriSyntaxFlags.AllowDnsHost) != 0) && !iriParsing &&
           DomainNameHelper.IsValid(pString, start, ref end, ref dnsNotCanonical, StaticNotAny(flags, Flags.ImplicitFile)))
            {
                // comes here if there are only ascii chars in host with original parsing and no Iri

                flags |= Flags.DnsHostType;
                if (!dnsNotCanonical)
                {
                    flags |= Flags.CanonicalDnsHost;
                }

                if ((s_IdnScope != UriIdnScope.None))
                {
                    // check if intranet
                    //
                    if ((s_IdnScope == UriIdnScope.AllExceptIntranet) && IsIntranet(new string(pString, 0, end)))
                    {
                        flags |= Flags.IntranetUri;
                    }
                    if (AllowIdnStatic(syntax, flags))
                    {
                        bool allAscii = true;
开发者ID:shmao,项目名称:corefx,代码行数:67,代码来源:Uri.cs


注:本文中的System.UriParser.NotAny方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。