• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# System.Uri类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Uri的典型用法代码示例。如果您正苦于以下问题:C# System.Uri类的具体用法?C# System.Uri怎么用?C# System.Uri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



System.Uri类属于命名空间,在下文中一共展示了System.Uri类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CSBuildProject

        public CSBuildProject(
            string moduleName,
            string projectPathName,
            Bam.Core.PackageIdentifier packageId,
            Bam.Core.ProxyModulePath proxyPath)
        {
            this.ProjectName = moduleName;
            this.PathName = projectPathName;
            this.PackageDirectory = packageId.Location;
            if (null != proxyPath)
            {
                this.PackageDirectory = proxyPath.Combine(packageId.Location);
            }

            var packagePath = this.PackageDirectory.GetLocations()[0].AbsolutePath;

            var isPackageDirAbsolute = Bam.Core.RelativePathUtilities.IsPathAbsolute(packagePath);
            var kind = isPackageDirAbsolute ? System.UriKind.Absolute : System.UriKind.Relative;

            if (packagePath[packagePath.Length - 1] == System.IO.Path.DirectorySeparatorChar)
            {
                this.PackageUri = new System.Uri(packagePath, kind);
            }
            else
            {
                this.PackageUri = new System.Uri(packagePath + System.IO.Path.DirectorySeparatorChar, kind);
            }

            this.ProjectGuid = new DeterministicGuid(this.PathName).Guid;
        }
开发者ID:markfinal,项目名称:bam-csharp,代码行数:30,代码来源:CSBuildProject.cs


示例2: DebugTest2

        static void DebugTest2()
        {
            string path1 = "/Users/Elyn/Projects/UnityPlugins/Unity Sandbox Project/Assets/Modules/GameCenter/Editor/iOS/GameCenterManager.m";
            string path2 = "/Users/Elyn/Projects/UnityPlugins/Unity Sandbox Project/XCode/.";

            System.Uri fileURI = new System.Uri( path1 );
            System.Uri rootURI = new System.Uri( path2 );
            Debug.Log( fileURI.MakeRelativeUri( rootURI ).ToString() );
            Debug.Log( rootURI.MakeRelativeUri( fileURI ).ToString() );

            //			string projectPath = Path.Combine( Directory.GetParent( Application.dataPath ).ToString(), "XCode" );

            //			string[] files = System.IO.Directory.GetFiles( projectPath, "Info.plist" );
            //			string contents = System.IO.File.OpenText( files[0] ).ReadToEnd();

            //			string[] projects = System.IO.Directory.GetDirectories( projectPath, "*.xcodeproj" );
            //			string projPath = System.IO.Path.Combine( projects[0], "project.pbxproj" );
            //			string contents = System.IO.File.OpenText( projPath ).ReadToEnd();
            //			Debug.Log( System.IO.File.OpenText( projPath ).ReadToEnd );

            //			PBXParser parser = new PBXParser();
            //			Hashtable test = (Hashtable)parser.Decode( contents );
            //			PBXDictionary test = parser.Decode( contents );
            //			Debug.Log( MiniJSON.jsonEncode( test ) );
            //			Debug.Log( test + " - " + test.Count );
            //			Debug.Log( parser.Encode( test ) );
        }
开发者ID:darktable,项目名称:XCodeEditor-for-Unity,代码行数:27,代码来源:XCodeEditorMenu.cs


示例3: getRelativePathTo

 public static string getRelativePathTo(this string path, string basePath)
 {
     System.Uri uri1 = new System.Uri(path);
     System.Uri uri2 = new System.Uri(basePath);
     System.Uri relativeUri = uri2.MakeRelativeUri(uri1);
     return relativeUri.ToString();
 }
开发者ID:polycular,项目名称:oekogotschi,代码行数:7,代码来源:PathExtensions.cs


示例4: IsPathAbsolute

 IsPathAbsolute(
     string path)
 {
     var pathUri = new System.Uri(path, System.UriKind.RelativeOrAbsolute);
     var isAbsolute = pathUri.IsAbsoluteUri;
     return isAbsolute;
 }
开发者ID:knocte,项目名称:BuildAMation,代码行数:7,代码来源:RelativePathUtilities.cs


示例5: HandleOpenURL

		public override bool HandleOpenURL(UIApplication application, NSUrl url)
		{
			if (url == null)
				return false;
			var uri = new System.Uri(url.ToString());

//			if (Slideout != null)
//			{
//				if (!string.IsNullOrEmpty(uri.Host))
//				{
//					string username = uri.Host;
//					string repo = null;
//
//					if (uri.Segments.Length > 1)
//						repo = uri.Segments[1].Replace("/", "");
//
//					if (repo == null)
//						Slideout.SelectView(new CodeBucket.ViewControllers.ProfileViewController(username));
//					else
//						Slideout.SelectView(new CodeBucket.ViewControllers.RepositoryInfoViewController(username, repo, repo));
//				}
//			}

			return true;
		}
开发者ID:jsuo,项目名称:CodeBucket,代码行数:25,代码来源:AppDelegate.cs


示例6: Write

        public static void Write(HttpContext context, string file)
        {
            var md = new MarkdownSharp.Markdown();
            context.Response.ContentType = "text/html";

            // < html xmlns = ""http://www.w3.org/1999/xhtml"">
            context.Response.Output.Write(@"<!DOCTYPE html>
            <html>
            <head>
            <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1"" />
            <meta charset=""utf-8"">
            <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
            <title>");

            context.Response.Output.Write(System.IO.Path.GetFileNameWithoutExtension(file));

            context.Response.Output.Write(@"</title>
            <meta http-equiv=""cache-control"" content=""max-age=0"" />
            <meta http-equiv=""cache-control"" content=""no-cache"" />
            <meta http-equiv=""expires"" content=""0"" />
            <meta http-equiv=""expires"" content=""Tue, 01 Jan 1980 1:00:00 GMT"" />
            <meta http-equiv=""pragma"" content=""no-cache"" />

            <base href =""/ajax/Resource.ashx/");
            context.Response.Output.Write(System.Web.HttpUtility.UrlPathEncode(
            Base64Encode(System.IO.Path.GetDirectoryName(file))
             ));
            context.Response.Output.Write(@"/"" />
            <link rel=""canonical"" href=""");

            string str = new System.Uri(file).AbsoluteUri;
            context.Response.Output.Write(str);

            context.Response.Output.Write(@""" />");

            context.Response.Output.Write("<style type=\"text/css\">");

            // http://stackoverflow.com/questions/6784799/what-is-this-char-65279
            // It's a zero-width no-break space. It's more commonly used as a byte-order mark (BOM).
            // context.Response.WriteFile(System.Web.Hosting.HostingEnvironment.MapPath("~/style.css"));
            // http://www.fileformat.info/info/unicode/char/feff/index.htm
            // \32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\64\102\111\110\116\45\102\97\99\101\32\123
            // \32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\65279\64\102\111\110\116\45\102\97\99\101\32\123

            context.Response.Output.Write(
                System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/style.css"), System.Text.Encoding.UTF8)
            );
            context.Response.Output.Write("</style>");

            context.Response.Output.Write(@"
            <link type=""text/css"" rel=""stylesheet"" href=""Content/style.css"" />
            <script type=""text/javascript"" src=""./Scripts/libs/jquery.js""></script>
            </head>
            <body>
            ");

            context.Response.Output.Write(md.Transform(System.IO.File.ReadAllText(file)));
            context.Response.Output.Write(@"</body></html>");
        }
开发者ID:ststeiger,项目名称:Svg3Dtest,代码行数:59,代码来源:MarkDownWriter.cs


示例7: DefaultUrlService

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="baseUri">The base Uri of all services.</param>
        /// <param name="servicePrefix">If we need a prefix to be appended to the base Uri.</param>
        public DefaultUrlService(System.Uri baseUri, string servicePrefix)
        {
            if(baseUri == null)
                throw new System.ArgumentNullException("baseUri");

            _baseUri = baseUri;
            ServicePrefix = servicePrefix;
        }
开发者ID:KCL5South,项目名称:WhippedCream,代码行数:13,代码来源:DefaultUrlService.cs


示例8: OnStartup

 protected override void OnStartup(StartupEventArgs e)
 {
     if (e.Args.Any())
     {
         Properties["ArbitraryArgName"] = new System.Uri(e.Args[0]);
     }
     base.OnStartup(e);
 }
开发者ID:domaspaukstys,项目名称:ChordsKaraoke,代码行数:8,代码来源:App.xaml.cs


示例9: testWebRequestGet

 public void testWebRequestGet()
 {
     var uri = new Uri("http://www.google.com");
     using(var stream  = WebInvoke( uri, Verb.Get, null,true))
     {
         AssertTrue(stream.Length > 100);
     }
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:8,代码来源:TestHttpWebRequest.cs


示例10: Constructor_BaseUrlReturnsCorrectValue

        public void Constructor_BaseUrlReturnsCorrectValue()
        {
            System.Uri baseUri = new System.Uri("http://www.google.com");
            IUrlService service = new DefaultUrlService(baseUri, null);

            Assert.AreEqual(baseUri.ToString(), service.BaseUrl, @"
            The BaseUrl property should return the value of the uri that was passed to the constructor.
            ");
        }
开发者ID:KCL5South,项目名称:WhippedCream,代码行数:9,代码来源:DefaultUrlServiceTests.cs


示例11: GetWebResponse

 protected override System.Net.WebResponse GetWebResponse(System.Net.WebRequest request)
 {
     System.Net.WebResponse response = base.GetWebResponse(request);
     if (response != null)
     {
         _responseUri = response.ResponseUri;
     }
     return response;
 }
开发者ID:RyanFu,项目名称:A51C1B616A294D4BBD6D3D46FD7F78A7,代码行数:9,代码来源:ResponseUriClient.cs


示例12: PhotoVersion

		public PhotoVersion (Photo photo, uint version_id, System.Uri uri, string md5_sum, string name, bool is_protected)
		{
			this.photo = photo;
			this.version_id = version_id;
			this.uri = uri;
			this.md5_sum = md5_sum;
			this.name = name;
			this.is_protected = is_protected;
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:9,代码来源:PhotoVersion.cs


示例13: GetServiceUri_PathNoPreceedingSlash

        public void GetServiceUri_PathNoPreceedingSlash()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "api");

            Assert.AreEqual(new System.Uri("https://www.cnn.gov/api/RelativeServicePath/PathAgain"), service.GetServiceUri("RelativeServicePath/PathAgain"), @"
            The GetServiceUri should take in a path and append the service prefix to the base url, then append
            the path to the result of that.
            ");
        }
开发者ID:KCL5South,项目名称:WhippedCream,代码行数:10,代码来源:DefaultUrlServiceTests.cs


示例14: DnnUnitTest

        public DnnUnitTest()
        {
            var uri = new System.Uri(Assembly.GetExecutingAssembly().CodeBase);
            string path = HttpUtility.UrlDecode(Path.GetFullPath(uri.AbsolutePath));

            WebsiteAppPath = "http://localhost/DNN_Platform";
            var websiteRootPath = path.Substring(0, path.IndexOf("DNN Platform", System.StringComparison.Ordinal));
            WebsitePhysicalAppPath = Path.Combine(websiteRootPath, "Website");
            HighlightDataPath = Path.Combine(websiteRootPath, "DNN Platform//Modules//PreviewProfileManagement//Resources//highlightDevices.xml");
        }
开发者ID:rjallepalli,项目名称:PIX_CMS,代码行数:10,代码来源:DnnUnitTest.cs


示例15: GetServiceUri_PathNull

        public void GetServiceUri_PathNull()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "api");

            Assert.AreEqual(new System.Uri("https://www.cnn.gov/api"), service.GetServiceUri(null), @"
            The GetServiceUri should take in a path and append the service prefix to the base url, then append
            the path to the result of that.

            If we pass null in for the path, then it should be ignored.
            ");
        }
开发者ID:KCL5South,项目名称:WhippedCream,代码行数:12,代码来源:DefaultUrlServiceTests.cs


示例16: GetServiceUri_PathPreceedingSlash

        public void GetServiceUri_PathPreceedingSlash()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "/api");

            Assert.AreEqual(new System.Uri("https://www.cnn.gov/api/RelativeServicePath/PathAgain"), service.GetServiceUri("/RelativeServicePath/PathAgain"), @"
            The GetServiceUri should take in a path and append the service prefix to the base url, then append
            the path to the result of that.

            Having a preceeding slash before the path should not prevent the service from creating
            a valid url.
            ");
        }
开发者ID:KCL5South,项目名称:WhippedCream,代码行数:13,代码来源:DefaultUrlServiceTests.cs


示例17: ChangesetSampleData

		public ChangesetSampleData()
		{
			try
			{
				System.Uri resourceUri = new System.Uri("/Smeedee.Widget.SourceControl.SL;component/SampleData/ChangesetSampleData/ChangesetSampleData.xaml", System.UriKind.Relative);
				if (System.Windows.Application.GetResourceStream(resourceUri) != null)
				{
					System.Windows.Application.LoadComponent(this, resourceUri);
				}
			}
			catch (System.Exception )
			{ }
		}
开发者ID:ArildF,项目名称:Smeedee,代码行数:13,代码来源:ChangesetSampleData.xaml.cs


示例18: IsLocalFileSystemWebService

 private bool IsLocalFileSystemWebService(string url)
 {
     if (string.IsNullOrEmpty(url))
     {
         return false;
     }
     var wsUri = new System.Uri(url);
     if (((wsUri.Port >= 1024)
                 && (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0)))
     {
         return true;
     }
     return false;
 }
开发者ID:Why-Not-Sky,项目名称:WorkflowEngine.NET,代码行数:14,代码来源:GetDocStatus.cs


示例19: LoadContent

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // URL MUST be relative in MonoGame
            System.Uri uri = new System.Uri("content/background.mp3",System.UriKind.Relative);
            Song song = Song.FromUri("mySong", uri);
            MediaPlayer.Play(song);
            MediaPlayer.ActiveSongChanged += (s, e) => {
                song.Dispose();
                System.Diagnostics.Debug.WriteLine("Song ended and disposed");
            };
        }
开发者ID:serapth,项目名称:MonoGameBook,代码行数:18,代码来源:Game1.cs


示例20: WebInvoke

        private static Stream WebInvoke(Uri uri, Verb verb, Stream input, bool hasOutput)
        {
            var request = WebRequest.Create(uri);
            switch (verb)
            {
                case Verb.Get:
                    request.Method = "GET";
                    break;
                case Verb.Post:
                    request.Method = "POST";
                    break;
                case Verb.Put:
                    request.Method = "PUT";
                    break;
                case Verb.Delete:
                    request.Method = "DELETE";
                    break;
            }

            WebResponse response;

            if (input != null)
            {
                input.Seek(0, SeekOrigin.Begin);

                request.ContentType = "application/xml";
                request.ContentLength = input.Length;

                using (var requestStream = request.GetRequestStream())
                {
                    var bytes = new byte[1024];
                    var read = 1;
                    while (read > 0)
                    {
                        read = input.Read(bytes, 0, bytes.Length);
                        requestStream.Write(bytes, 0, read);
                    }
                }
            }

            using (response = request.GetResponse())
			{
				if (!hasOutput)
					return null;
				var temp = new MemoryStream();
				response.GetResponseStream().CopyTo(temp);
				temp.Seek(0L, SeekOrigin.Begin);
				return temp;
			}
        }
开发者ID:Xtremrules,项目名称:dot42,代码行数:50,代码来源:TestHttpWebRequest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Web.Mvc类代码示例发布时间:2022-05-24
下一篇:
C# System.UInt32类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap