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


C# System.Url类代码示例

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


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


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