本文整理汇总了C#中UriKind类的典型用法代码示例。如果您正苦于以下问题:C# UriKind类的具体用法?C# UriKind怎么用?C# UriKind使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UriKind类属于命名空间,在下文中一共展示了UriKind类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Virusface,项目名称:yam-dotnet,代码行数:13,代码来源:StringExtension.cs
示例2: ValidatePackageUri
private void ValidatePackageUri(string packageUri, UriKind allowedUriKind)
{
if (!_galleryUriValidator.IsValidUri(packageUri, allowedUriKind))
{
throw new UriFormatException(packageUri);
}
}
开发者ID:dioptre,项目名称:nkd,代码行数:7,代码来源:PackageUriValidator.cs
示例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;
}
开发者ID:anytao,项目名称:ModernReader,代码行数:30,代码来源:TextParser.cs
示例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);
}
开发者ID:omnimark,项目名称:PTVS,代码行数:7,代码来源:CommonUtils.cs
示例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();
}
开发者ID:Aadeelyoo,项目名称:MyMSDNSamples,代码行数:7,代码来源:Reference.cs
示例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));
}
}
}
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:28,代码来源:SerializationUtility.cs
示例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;
}
开发者ID:HETUAN,项目名称:PersonalInfoForWPF,代码行数:13,代码来源:ImageUtils.cs
示例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);
}
开发者ID:rhdlmv,项目名称:test1,代码行数:9,代码来源:MainPage.xaml.cs
示例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;
}
开发者ID:Konctantin,项目名称:Puzzle,代码行数:8,代码来源:MainWindow.xaml.cs
示例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;
}
开发者ID:richardszalay,项目名称:mockhttp,代码行数:9,代码来源:UriUtil.cs
示例11: ToUri
public static Uri ToUri(string value, UriKind uriKind)
{
Uri uri;
Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out uri);
return uri;
}
开发者ID:joncrump,项目名称:Jon.Crump.Common,代码行数:8,代码来源:StringExtensions.cs
示例12: GetImage
public static Image GetImage(String uri, Style style, UriKind uriKind)
{
return new Image
{
Source = GetImageSource(uri, uriKind),
Style = style,
};
}
开发者ID:wjzhangb,项目名称:Fantasy.Repositories,代码行数:8,代码来源:FantasyUtility.cs
示例13: ToUri
public static Uri ToUri(this string target, UriKind uriKind)
{
if (target == null)
{
return null;
}
return new Uri(target, uriKind);
}
开发者ID:endjin,项目名称:openrasta-stable,代码行数:9,代码来源:StringExtensions.cs
示例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;
}
开发者ID:lavnok,项目名称:Utils,代码行数:9,代码来源:ValidationHelper.cs
示例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;
}
开发者ID:joazlazer,项目名称:ModdingStudio,代码行数:16,代码来源:MainProjectTypes.cs
示例16: TryParseComponents
public static bool TryParseComponents(string uri, UriKind kind, out UriElements elements, out string error)
{
uri = uri.Trim();
ParserState state = new ParserState(uri, kind);
elements = state.elements;
error = null;
if (uri.Length == 0 && (kind == UriKind.Relative || kind == UriKind.RelativeOrAbsolute))
{
state.elements.isAbsoluteUri = false;
return true;
}
if (uri.Length <= 1 && kind == UriKind.Absolute)
{
error = "Absolute URI is too short";
return false;
}
bool ok = ParseFilePath(state) &&
ParseScheme(state);
var scheme = state.elements.scheme;
UriParser parser = null;
if (!StringUtilities.IsNullOrEmpty(scheme))
{
parser = UriParser.GetParser(scheme);
if (parser != null && !(parser is DefaultUriParser))
return true;
}
ok = ok &&
ParseAuthority(state) &&
ParsePath(state) &&
ParseQuery(state) &&
ParseFragment(state);
if (StringUtilities.IsNullOrEmpty(state.elements.host) &&
(scheme == Uri.UriSchemeHttp || scheme == Uri.UriSchemeGopher || scheme == Uri.UriSchemeNntp ||
scheme == Uri.UriSchemeHttps || scheme == Uri.UriSchemeFtp))
state.error = "Invalid URI: The Authority/Host could not be parsed.";
if (!StringUtilities.IsNullOrEmpty(state.elements.host) &&
Uri.CheckHostName(state.elements.host) == UriHostNameType.Unknown)
state.error = "Invalid URI: The hostname could not be parsed.";
if (!StringUtilities.IsNullOrEmpty(state.error))
{
elements = null;
error = state.error;
return false;
}
return true;
}
开发者ID:T-REX-XP,项目名称:serialwifi,代码行数:56,代码来源:UriParseComponents.cs
示例17: ParseComponents
public static UriElements ParseComponents (string uri, UriKind kind)
{
UriElements elements;
string error;
if (!TryParseComponents (uri, kind, out elements, out error))
throw new UriFormatException (error);
return elements;
}
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:10,代码来源:UriParseComponents.cs
示例18: CreateUri
public Uri CreateUri(object parameters, UriKind kind = UriKind.Relative) {
string href = this.Href;
foreach (PropertyInfo substitution in parameters.GetType().GetProperties()) {
string name = substitution.Name;
object value = substitution.GetValue(parameters, null);
string substituionValue = value == null ? null : Uri.EscapeDataString(value.ToString());
href = href.Replace(string.Format("{{{0}}}", name), substituionValue);
}
return new Uri(href, kind);
}
开发者ID:StevenArnauts,项目名称:appserver,代码行数:10,代码来源:Link.cs
示例19: NavigationItem
public NavigationItem(string containerRegisteredName, UriKind uriKind)
{
if (String.IsNullOrEmpty(containerRegisteredName))
{
throw new ArgumentNullException("containerRegisteredName");
}
ContainerRegisteredName = containerRegisteredName;
Uri = new Uri(ContainerRegisteredName, UriKind.Relative);
}
开发者ID:ssommerf,项目名称:Gateworld.Sharp,代码行数:12,代码来源:NavigationItem.cs
示例20: FastBitmap
public FastBitmap(string filename, UriKind uriKind = UriKind.Absolute)
{
// Use BitmapCacheOption.OnLoad to avoid file locks (thanks Mikhail-Fiadosenka).
// http://social.msdn.microsoft.com/forums/en-US/wpf/thread/3738345b-a6cc-421d-a98f-d907292d6e35/
var image = new BitmapImage();
image.BeginInit();
image.CacheOption = BitmapCacheOption.OnLoad;
image.UriSource = new Uri(filename, uriKind);
image.EndInit();
InnerBitmap = new WriteableBitmap(ConvertFormat(image));
}
开发者ID:pacificIT,项目名称:dynamic-image,代码行数:12,代码来源:FastBitmap.cs
注:本文中的UriKind类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论