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


C# UriKind类代码示例

本文整理汇总了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);
 }
开发者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


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