本文整理汇总了C#中Uri.IsWellFormedOriginalString方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.IsWellFormedOriginalString方法的具体用法?C# Uri.IsWellFormedOriginalString怎么用?C# Uri.IsWellFormedOriginalString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri.IsWellFormedOriginalString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsWellFormedOriginalString
protected internal virtual bool IsWellFormedOriginalString(Uri uri)
{
// well formed according to RFC2396 and RFC2732
// see Uri.IsWellFormedOriginalString for some docs
// Though this class does not seem to do anything. Even null arguments aren't checked :/
return uri.IsWellFormedOriginalString();
}
示例2: URLValidator_ServerValidate
protected void URLValidator_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = false;
TextBox URLTextBox = AdFormView.FindControl("URLTextBox") as TextBox;
if (URLTextBox != null && !URLTextBox.Text.Equals(String.Empty))
{
try
{
Uri uri = new Uri(URLTextBox.Text);
if (uri.IsWellFormedOriginalString() &
(uri.Scheme == "http" | uri.Scheme == "https"))
{
args.IsValid = true;
}
}
catch
{
}
}
else
{
// Empty URL is okay.
args.IsValid = true;
}
}
示例3: TestIsWellFormedOriginalString
public static void TestIsWellFormedOriginalString()
{
Uri uri;
bool b;
uri = new Uri("http://www.contoso.com/path?name");
b = uri.IsWellFormedOriginalString();
Assert.True(b);
uri = new Uri("http://www.contoso.com/path???/file name");
b = uri.IsWellFormedOriginalString();
Assert.False(b);
uri = new Uri(@"c:\\directory\filename");
b = uri.IsWellFormedOriginalString();
Assert.False(b);
uri = new Uri(@"file://c:/directory/filename");
b = uri.IsWellFormedOriginalString();
Assert.False(b);
uri = new Uri(@"http:\\host/path/file");
b = uri.IsWellFormedOriginalString();
Assert.False(b);
}
示例4: IsWellFormedOriginalString
public void IsWellFormedOriginalString(string uriString, bool expected)
{
Uri uri = new Uri(uriString);
Assert.Equal(expected, uri.IsWellFormedOriginalString());
}