當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。