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

C# System.Url类代码示例

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

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



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

示例1: action_Click

        protected void action_Click(object sender, EventArgs e)
        {
            string url = input.Text;
            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            // Execute methods on the UrlShortener service based upon the type of the URL provided.
            try
            {
                string resultURL;
                if (IsShortUrl(url))
                {
                    // Expand the URL by using a Url.Get(..) request.
                    Url result = service.Url.Get(url).Execute();
                    resultURL = result.LongUrl;
                }
                else
                {
                    // Shorten the URL by inserting a new Url.
                    Url toInsert = new Url { LongUrl = url };
                    toInsert = service.Url.Insert(toInsert).Execute();
                    resultURL = toInsert.Id;
                }
                output.Text = string.Format("<a href=\"{0}\">{0}</a>", resultURL);
            }
            catch (GoogleApiException ex)
            {
                var str = ex.ToString();
                str = str.Replace(Environment.NewLine, Environment.NewLine + "<br/>");
                str = str.Replace("  ", " &nbsp;");
                output.Text = string.Format("<font color=\"red\">{0}</font>", str);
            }
        }
开发者ID:leehom59,项目名称:google-api-dotnet-client-samples,代码行数:35,代码来源:Default.aspx.cs


示例2: VirtualFileStore

        public VirtualFileStore(string virtualPathProviderName)
        {
            if (string.IsNullOrEmpty(virtualPathProviderName))
            {
                throw new ArgumentNullException("virtualPathProviderName");
            }

            var vppRegistrationHandler = ServiceLocator.Current.GetInstance<VirtualPathRegistrationHandler>();
            var storeVirtualPathProviderSettings = vppRegistrationHandler.RegisteredVirtualPathProviders.Values.FirstOrDefault(ps => ps.Name == virtualPathProviderName);

            if (storeVirtualPathProviderSettings == null)
            {
                throw new ArgumentException(string.Format("Virtual path provider with name \"{0}\" has not been registered, please check EPiServerFramwork.config file.", virtualPathProviderName), "virtualPathProviderName");
            }

            string storePath = storeVirtualPathProviderSettings.Parameters["physicalPath"];
            string storeUrl = storeVirtualPathProviderSettings.Parameters["virtualPath"];

            if (string.IsNullOrEmpty(storePath) || string.IsNullOrEmpty(storeUrl))
            {
                throw new ConfigurationErrorsException(@"Target virtual path provider is not well configured, ""physicalPath"" and ""virtualPath"" parameters are required.");
            }

            _storePath = VirtualPathUtilityEx.RebasePhysicalPath(storePath);
            _storeUrl = Url.Parse(storeUrl);

            if (!Directory.Exists(_storePath))
            {
                Directory.CreateDirectory(_storePath);
            }
        }
开发者ID:whyleee,项目名称:RestImageResize,代码行数:31,代码来源:VirtualFileStore.cs


示例3: RegisterEntryPointControllerDescriptionBuilder

 private static void RegisterEntryPointControllerDescriptionBuilder(this IComponentProvider container, Url entryPoint)
 {
     container.Register<IHttpControllerDescriptionBuilder, EntryPointControllerDescriptionBuilder>(
         entryPoint.ToString().Substring(1),
         () => new EntryPointControllerDescriptionBuilder(entryPoint, container.Resolve<IDefaultValueRelationSelector>()),
         Lifestyles.Singleton);
 }
开发者ID:alien-mcl,项目名称:URSA,代码行数:7,代码来源:ComponentProviderExtensions.cs


示例4: Response

 public Response(String message, Url address)
 {
     var buffer = Encoding.UTF8.GetBytes(message);
     _content = new MemoryStream(buffer);
     _headers = new Dictionary<String, String>();
     _address = address;
 }
开发者ID:AlgorithmsAreCool,项目名称:AngleSharp.Scripting,代码行数:7,代码来源:DelayedRequester.cs


示例5: Account

        internal Account(Newtonsoft.Json.Linq.JToken json) : this()
        {
            IsDeactivated             = (bool)json["deactivated"];
            IsWithdrawalHalted        = (bool)json["withdrawal_halted"];
            IsSweepEnabled            = (bool)json["sweep_enabled"];
            OnlyPositionClosingTrades = (bool)json["only_position_closing_trades"];

            UpdatedAt = (DateTime)json["updated_at"];

            AccountUrl    = new Url<Account>((string)json["url"]);
            PortfolioUrl  = new  Url<AccountPortfolio>((string)json["portfolio"]);
            UserUrl       = new Url<User>((string)json["user"]);
            PositionsUrl  = new  Url<AccountPositions>((string)json["positions"]);

            AccountNumber = (string)json["account_number"];
            AccountType   = (string)json["type"];

            Sma = json["sma"];
            SmaHeldForOrders = json["sma_held_for_orders"];

            MarginBalances = json["margin_balances"];

            MaxAchEarlyAccessAmount = (decimal)json["max_ach_early_access_amount"];

            CashBalance = new Balance(json["cash_balances"]);
        }
开发者ID:wchuanghard,项目名称:RobinhoodNet,代码行数:26,代码来源:Account.cs


示例6: RewriteUrl

        public string RewriteUrl(string url)
        {
            if(url.Contains("productid"))
            {
                // Give it a thorough look - see if we can redirect it
                Url uri = new Url(url);
                string[] productIds = uri.QueryCollection.GetValues("productid");
                if(productIds != null && productIds.Any())
                {
                    string productId = productIds.FirstOrDefault();

                    if (productId != null && string.IsNullOrEmpty(productId) == false)
                    {
                        SearchResults<FindProduct> results = SearchClient.Instance.Search<FindProduct>()
                            .Filter(p => p.Code.MatchCaseInsensitive(productId))
                            .GetResult();
                        if (results.Hits.Any())
                        {
                            // Pick the first one
                            SearchHit<FindProduct> product = results.Hits.FirstOrDefault();
                            return product.Document.ProductUrl;
                        }
                    }

                }
            }
            return null;
        }
开发者ID:episerver,项目名称:Commerce-Demo-Kit,代码行数:28,代码来源:CustomProductRedirectHandler.cs


示例7: action_Click

        protected void action_Click(object sender, EventArgs e)
        {
            string url = input.Text;
            if (string.IsNullOrEmpty(url))
            {
                return;
            }

            // Execute methods on the UrlShortener service based upon the type of the URL provided.
            try
            {
                string resultURL;
                if (IsShortUrl(url))
                {
                    // Expand the URL by using a Url.Get(..) request.
                    Url result = _service.Url.Get(url).Fetch();
                    resultURL = result.LongUrl;
                }
                else
                {
                    // Shorten the URL by inserting a new Url.
                    Url toInsert = new Url { LongUrl = url};
                    toInsert = _service.Url.Insert(toInsert).Fetch();
                    resultURL = toInsert.Id;
                }
                output.Text = string.Format("<a href=\"{0}\">{0}</a>", resultURL);
            }
            catch (GoogleApiException ex)
            {
                output.Text = ex.ToHtmlString();
            }
        }
开发者ID:jithuin,项目名称:infogeezer,代码行数:32,代码来源:Default.aspx.cs


示例8: ResolveUrl

        public string ResolveUrl(Url url)
        {
            if (url == null) return string.Empty;

            var parsedUrl = ResolveUrl(PageReference.ParseUrl(url.OriginalString));
            return string.IsNullOrWhiteSpace(parsedUrl) ? url.OriginalString : parsedUrl;
        }
开发者ID:fulgore7,项目名称:JonDJones.com.EPiServerCreativeParallaxTemplae,代码行数:7,代码来源:LinkResolver.cs


示例9: Download

 public Download(Task<IResponse> task, CancellationTokenSource cts, Url target, INode originator)
 {
     _task = task;
     _cts = cts;
     _target = target;
     _originator = originator;
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:7,代码来源:Download.cs


示例10: Position

 internal Position(Newtonsoft.Json.Linq.JToken json)
     : this()
 {
     InstrumentUrl = new Url<Account>((string)json["instrument"]);
       AverageBuyPrice = (decimal)json["average_buy_price"];
       Quantity = (decimal)json["quantity"];
 }
开发者ID:itsff,项目名称:RobinhoodNet,代码行数:7,代码来源:Position.cs


示例11: RawPage

        /// <summary>
        /// Initializes a new instance of the <see cref="RawPage" /> class.
        /// </summary>
        /// <param name="uri">The uri to the page on the site</param>
        /// <param name="textData">Raw text of the page.</param>
        /// <param name="links">Links recovered from this page.</param>
        /// <param name="alternativePaths">The path the request was redirected to.</param>
        public RawPage(Uri uri, string textData, string reference, IEnumerable<Uri> links, params string[] alternativePaths)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }
            
            if (string.IsNullOrWhiteSpace(textData))
            {
                throw new ArgumentNullException("textData");
            }

            if (links == null)
            {
                throw new ArgumentNullException("links");
            }

            this.path = uri.PathAndQuery;
            this.url = new Url(uri);
            this.textData = textData;
            this.links = links.ToList();
            var alternative = (alternativePaths ?? Enumerable.Empty<string>())
                .Where(p => p != path);
            this.alternativePaths.AddRange(alternative);
            this.reference = reference;
        }
开发者ID:WebCentrum,项目名称:WebPackUI,代码行数:33,代码来源:RawPage.cs


示例12: FlurlClient

		public FlurlClient(Url url, bool autoDispose) {
			this.Url = url;
			this.AutoDispose = autoDispose;
			this.AllowedHttpStatusRanges = new List<string>();
			if (FlurlHttp.Configuration.AllowedHttpStatusRange != null)
				this.AllowedHttpStatusRanges.Add(FlurlHttp.Configuration.AllowedHttpStatusRange);
		}
开发者ID:carolynvs,项目名称:Flurl,代码行数:7,代码来源:FlurlClient.cs


示例13: GetSitemapData

        public SitemapData GetSitemapData(string requestUrl)
        {
            var url = new Url(requestUrl); 
            
            var host = url.Path.TrimStart('/').ToLowerInvariant();

            return GetAllSitemapData().FirstOrDefault(x => GetHostWithLanguage(x) == host && (x.SiteUrl == null || x.SiteUrl.Contains(url.Host)));
        }
开发者ID:jstemerdink,项目名称:SEO.Sitemaps,代码行数:8,代码来源:SitemapRepository.cs


示例14: VirtualResponse

 private VirtualResponse()
 {
     _address = Url.Create("http://localhost/");
     _status = HttpStatusCode.OK;
     _headers = new Dictionary<String, String>();
     _content = MemoryStream.Null;
     _dispose = false;
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:8,代码来源:VirtualResponse.cs


示例15: UrlWithHttpAsResourceIsARelativeUrl

 public void UrlWithHttpAsResourceIsARelativeUrl()
 {
     var address = "http";
     var result = new Url(address);
     Assert.That(result.IsInvalid, Is.False);
     Assert.That(result.Href, Is.EqualTo("http"));
     Assert.That(result.IsRelative, Is.True);
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:8,代码来源:Url.cs


示例16: EdgeMart

 // constructors
 /// <summary>
 /// Creates a new member of EdgeMart.
 /// </summary>
 /// <param name="url">Server and EdgeMart settings in the form of a Url.</param>
 protected EdgeMart(Url url)
 {
     if (url == null) throw new ArgumentNullException("url");
     if (String.IsNullOrEmpty(url.EdgeMartName))
     {
         throw new ArgumentException("The name of the EdgeMart is required.");
     }
     _url = url;
 }
开发者ID:sprucemedia,项目名称:oinq,代码行数:14,代码来源:EdgeMart.cs


示例17: Get

 /// <summary>
 /// Creates a GET request for the given target from the optional source
 /// node and optional referer string.
 /// </summary>
 /// <param name="target">The target to use.</param>
 /// <param name="source">The optional source of the request.</param>
 /// <param name="referer">The optional referrer string.</param>
 /// <returns>The new document request.</returns>
 public static DocumentRequest Get(Url target, INode source = null, String referer = null)
 {
     return new DocumentRequest(target)
     {
         Method = HttpMethod.Get,
         Referer = referer,
         Source = source
     };
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:17,代码来源:DocumentRequest.cs


示例18: UrlWithSchemeOnlyIsAnInvalidUrl

 public void UrlWithSchemeOnlyIsAnInvalidUrl()
 {
     var address = "http://";
     var result = new Url(address);
     Assert.That(result.IsInvalid, Is.True);
     Assert.That(result.Href, Is.EqualTo("http:///"));
     Assert.That(String.IsNullOrEmpty(result.Path), Is.True);
     Assert.That(String.IsNullOrEmpty(result.Query), Is.True);
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:9,代码来源:Url.cs


示例19: UrlWithHttpAndColonIsAValidUrl

 public void UrlWithHttpAndColonIsAValidUrl()
 {
     var address = "http:";
     var result = new Url(address);
     Assert.That(result.IsInvalid, Is.False);
     Assert.That(result.Href, Is.EqualTo("http:///"));
     Assert.That(String.IsNullOrEmpty(result.Path), Is.True);
     Assert.That(String.IsNullOrEmpty(result.Query), Is.True);
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:9,代码来源:Url.cs


示例20: ChangeImageSourceWithAbsoluteUrlResultsInUpdatedAbsoluteUrl

 public void ChangeImageSourceWithAbsoluteUrlResultsInUpdatedAbsoluteUrl()
 {
     var document = CreateEmpty("http://localhost");
     var img = document.CreateElement<IHtmlImageElement>();
     img.Source = "http://www.test.com/test.png";
     Assert.AreEqual("http://www.test.com/test.png", img.Source);
     var url = new Url(img.Source);
     Assert.AreEqual("test.png", url.Path);
 }
开发者ID:Wojdav,项目名称:AngleSharp,代码行数:9,代码来源:DOMActions.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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