本文整理汇总了C#中System.UriParser.InFact方法的典型用法代码示例。如果您正苦于以下问题:C# UriParser.InFact方法的具体用法?C# UriParser.InFact怎么用?C# UriParser.InFact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UriParser
的用法示例。
在下文中一共展示了UriParser.InFact方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IriParsingStatic
private static bool IriParsingStatic(UriParser syntax)
{
if (!s_IriParsing)
{
return false;
}
return (((syntax != null) && syntax.InFact(UriSyntaxFlags.AllowIriParsing)) || (syntax == null));
}
示例2: StaticIsFile
private static bool StaticIsFile(UriParser syntax)
{
return syntax.InFact(UriSyntaxFlags.FileLikeUri);
}
示例3: 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;
//.........这里部分代码省略.........
示例4: 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;
}
示例5: 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 == '/')
{
//.........这里部分代码省略.........
示例6: 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)
{
//.........这里部分代码省略.........
示例7: IriParsingStatic
//
// Statically checks if Iri parsing is allowed by the syntax & by config
//
internal static bool IriParsingStatic(UriParser syntax)
{
return (s_IriParsing && (((syntax != null) && syntax.InFact(UriSyntaxFlags.AllowIriParsing)) ||
(syntax == null)));
}