本文整理汇总了C#中UriKind类的典型用法代码示例。如果您正苦于以下问题:C# UriKind类的具体用法?C# UriKind怎么用?C# UriKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriKind类属于命名空间,在下文中一共展示了UriKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToUri
/// <summary>
/// Convert the string to a valid URI.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="uriKind">The uri kind.</param>
/// <returns>The <see cref="Uri"/>, or null if it is invalid URI.</returns>
public static Uri ToUri(this string value, UriKind uriKind = UriKind.Absolute)
{
return
(string.IsNullOrWhiteSpace(value) || !Uri.IsWellFormedUriString(value, uriKind))
? null
: new Uri(value, uriKind);
}
示例2: ValidatePackageUri
private void ValidatePackageUri(string packageUri, UriKind allowedUriKind)
{
if (!_galleryUriValidator.IsValidUri(packageUri, allowedUriKind))
{
throw new UriFormatException(packageUri);
}
}
示例3: GetBook
public static Book GetBook(string url, UriKind urikind)
{
Book result = new Book();
string content = AtFile.GetContent(url, 4);
MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(content));
StreamReader reader = null;
try
{
reader = new StreamReader(stream);
string str2 = null;
while ((str2 = reader.ReadLine()) != null)
{
string[] strArray = str2.Replace("&&", "&").Split(new char[] { '&' });
if (strArray.Length >= 3)
{
Chapter item = new Chapter();
item.Title = strArray[0];
item.FileName = strArray[1];
item.Size = int.Parse(strArray[2]);
result.Chapters.Add(item);
}
}
reader.Close();
}
catch (NullReferenceException ex)
{
}
return result;
}
示例4: TryMakeUri
internal static bool TryMakeUri(string path, bool isDirectory, UriKind kind, out Uri uri) {
if (isDirectory && !string.IsNullOrEmpty(path) && !HasEndSeparator(path)) {
path += Path.DirectorySeparatorChar;
}
return Uri.TryCreate(path, kind, out uri);
}
示例5: NetflixCatalog
public NetflixCatalog(Uri serviceRoot, UriKind absolute) :
base(serviceRoot)
{
this.ResolveName = new global::System.Func<global::System.Type, string>(this.ResolveNameFromType);
this.ResolveType = new global::System.Func<string, global::System.Type>(this.ResolveTypeFromName);
this.OnContextCreated();
}
示例6: ParseUriList
public static void ParseUriList(string listOfUrisAsString, Collection<Uri> uriCollection, UriKind uriKind)
{
Fx.Assert(listOfUrisAsString != null, "The listOfUrisAsString must be non null.");
Fx.Assert(uriCollection != null, "The uriCollection must be non null.");
string[] uriStrings = listOfUrisAsString.Split(whiteSpaceChars, StringSplitOptions.RemoveEmptyEntries);
if (uriStrings.Length > 0)
{
for (int i = 0; i < uriStrings.Length; i++)
{
try
{
uriCollection.Add(new Uri(uriStrings[i], uriKind));
}
catch (FormatException fe)
{
if (uriKind == UriKind.Absolute)
{
throw FxTrace.Exception.AsError(new XmlException(SR2.DiscoveryXmlAbsoluteUriFormatError(uriStrings[i]), fe));
}
else
{
throw FxTrace.Exception.AsError(new XmlException(SR2.DiscoveryXmlUriFormatError(uriStrings[i]), fe));
}
}
}
}
}
示例7: GetBitmapSourceFromImageFileName
/// <summary>
/// 将图像文件(使用相对路径)转为BitmapSource对象
/// </summary>
/// <param name="ImageFileFullName"></param>
/// <returns></returns>
public static BitmapSource GetBitmapSourceFromImageFileName(string ImageFileName, UriKind uriKind)
{
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(ImageFileName, uriKind);
myBitmapImage.EndInit();
return myBitmapImage;
}
示例8: GetRichContent
//获取Rich Content
void GetRichContent(string uri, UriKind uk)
{
Container.Children.Clear();
ControlHtmlHost chtml = new ControlHtmlHost();
HtmlHost hh = chtml.FindName("htmlHost") as HtmlHost;
hh.SourceUri = new Uri(uri, uk);
Container.Children.Add(chtml);
}
示例9: LoadImage
void LoadImage(string path, UriKind uriKind = UriKind.Absolute)
{
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri(path, uriKind);
bitmap.EndInit();
Model.ImageSource = bitmap;
}
示例10: TryParse
// MonoAndroid parses relative URI's and adds a "file://" protocol, which causes the matcher to fail
public static bool TryParse(string url, UriKind kind, out Uri output)
{
bool systemResult = Uri.TryCreate(url, kind, out output);
bool isAndroidFalsePositive = systemResult && output.Scheme == "file" && !url.StartsWith("file://", StringComparison.Ordinal);
return systemResult && !isAndroidFalsePositive;
}
示例11: ToUri
public static Uri ToUri(string value, UriKind uriKind)
{
Uri uri;
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out uri);
return uri;
}
示例12: GetImage
public static Image GetImage(String uri, Style style, UriKind uriKind)
{
return new Image
{
Source = GetImageSource(uri, uriKind),
Style = style,
};
}
示例13: ToUri
public static Uri ToUri(this string target, UriKind uriKind)
{
if (target == null)
{
return null;
}
return new Uri(target, uriKind);
}
示例14: IsValidUri
internal static Uri IsValidUri(out bool isValid, string url, UriKind kind = UriKind.RelativeOrAbsolute)
{
isValid = false;
if(string.IsNullOrEmpty(url))
return null;
Uri temp;
isValid = Uri.TryCreate(url, kind, out temp);
return temp;
}
示例15: AddThumbnail
/// <summary>
/// Adds a thumbnail to the project type.
/// </summary>
/// <param name="location"></param>
/// <param name="kind"></param>
/// <param name="pt"></param>
/// <returns></returns>
public static ProjectType AddThumbnail(string location, UriKind kind, ProjectType pt)
{
BitmapImage logo = new BitmapImage();
logo.BeginInit();
logo.UriSource = new Uri(location, kind);
logo.EndInit();
pt.Icon = logo;
return pt;
}