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

C# Url类代码示例

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

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



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

示例1: execute0

 public override bool execute0(Url u)
 {
     if (u.getNome().Contains(parte))
         return true;
     else
         return false;
 }
开发者ID:ggsamsa,项目名称:webfolder,代码行数:7,代码来源:FiltroNome.cs


示例2: DownloadFile

        /// <summary>
        /// Download a file.
        /// </summary>
        /// <param name="path">Remote relative path of file to download.</param>
        /// <param name="to">Local absolute path to write the file.</param>
        /// <param name="errorHandler">The error handler.</param>
        /// <returns>The <see cref="Task"/>.</returns>
        /// <exception cref="NotADirectoryException">Si path indique un répertoire.</exception>
        public async Task DownloadFile(Url path, Url to, Action<HttpStatusCode, string> errorHandler)
        {
            if (to == null) throw new ArgumentNullException("to");
            var request = new RestRequest(path, Method.GET);

            var fileBytes = await this.Client.ExecuteGetTaskAsync(request);

            if (fileBytes.Headers.Any(h => h.Name == "is-directory"))
            {
                throw new NotADirectoryException();
            }

            if (fileBytes.StatusCode == HttpStatusCode.OK)
            {
                if (!Directory.Exists(to.GetDirectoryName()))
                {
                    Directory.CreateDirectory(to.GetDirectoryName());
                }

                File.WriteAllText(to.FullPath, fileBytes.Content, Encoding.Default);
            }
            else if (errorHandler != null)
            {
                errorHandler(fileBytes.StatusCode, fileBytes.StatusDescription);
            }
        }
开发者ID:SGrondin,项目名称:httpfs,代码行数:34,代码来源:HttpFileSystemProxy.cs


示例3: HandleRequest

 public void HandleRequest(Url url, NetworkStream stream)
 {
     foreach (IPlugin p in plugins)
     {
         p.handleRequest(url, stream);
     }
 }
开发者ID:karinmae,项目名称:SWE1,代码行数:7,代码来源:PluginManager.cs


示例4: Check

		public void Check ()
		{
			ApplicationDirectoryMembershipCondition ad = new ApplicationDirectoryMembershipCondition ();
			Evidence e = null;
			Assert.IsFalse (ad.Check (e), "Check (null)");
			e = new Evidence ();
			Assert.IsFalse (ad.Check (e), "Check (empty)");
			e.AddHost (new Zone (SecurityZone.MyComputer));
			Assert.IsFalse (ad.Check (e), "Check (zone)");

			string codebase = Assembly.GetExecutingAssembly ().CodeBase;
			Url u = new Url (codebase);
			ApplicationDirectory adir = new ApplicationDirectory (codebase);

			e.AddHost (u);
			Assert.IsFalse (ad.Check (e), "Check (url-host)"); // not enough
			e.AddAssembly (adir);
			Assert.IsFalse (ad.Check (e), "Check (url-host+adir-assembly)");

			e = new Evidence ();
			e.AddHost (adir);
			Assert.IsFalse (ad.Check (e), "Check (adir-host)"); // not enough
			e.AddAssembly (u);
			Assert.IsFalse (ad.Check (e), "Check (url-assembly+adir-host)");

			e = new Evidence ();
			e.AddHost (u);
			e.AddHost (adir);
			Assert.IsTrue (ad.Check (e), "Check (url+adir host)"); // both!!
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:30,代码来源:ApplicationDirectoryMembershipConditionTest.cs


示例5: GetLocationEmployees

 private static async Task<IEnumerable<string>> GetLocationEmployees(string location)
 {
     var request = new Url(BaseUrl).AppendPathSegments("deskplan", location, "employees.xml");
     var response = await request.GetStreamAsync();
     var xml = XDocument.Load(response);
     return xml.XPathSelectElements("//User").Select(u => u.Attribute(XName.Get("Name"))?.Value);
 }
开发者ID:jamiehumphries,项目名称:Skillz,代码行数:7,代码来源:Scraper.cs


示例6: ResolveUrl

        public virtual PathData ResolveUrl(Url url)
        {
            try
            {
                var path = parser.FindPath(url.RemoveDefaultDocument(Url.DefaultDocument).RemoveExtension(observedExtensions));

                path.CurrentItem = path.CurrentPage;

                if (draftRepository.Versions.TryParseVersion(url[PathData.VersionIndexQueryKey], url[PathData.VersionKeyQueryKey], path))
                    return path;

                string viewPreferenceParameter = url.GetQuery(WebExtensions.ViewPreferenceQueryString);
                if (viewPreferenceParameter == WebExtensions.DraftQueryValue && draftRepository.HasDraft(path.CurrentItem))
                {
                    var draft = draftRepository.Versions.GetVersion(path.CurrentPage);
					path.TryApplyVersion(draft, url["versionKey"], draftRepository.Versions);
                }

                return path;
            }
            catch (Exception ex)
            {
                errorHandler.Notify(ex);
            }
            return PathData.Empty;
        }
开发者ID:Biswo,项目名称:n2cms,代码行数:26,代码来源:RequestPathProvider.cs


示例7: execute0

 public override bool execute0(Url u)
 {
     if (base.GetDate().CompareTo(u.getDate()) < 0)
         return true;
     else
         return false;
 }
开发者ID:ggsamsa,项目名称:webfolder,代码行数:7,代码来源:FiltroDataMaior.cs


示例8: CanConvertImplicitlyToString

        public void CanConvertImplicitlyToString()
        {
            Url url = new Url(canonicalUrl1);
            string url2 = url;

            Assert.AreEqual(url, url2);
        }
开发者ID:candera,项目名称:tpanl,代码行数:7,代码来源:UrlTests.cs


示例9: EqualsReturnsFalseForInequivalentUrl

        public void EqualsReturnsFalseForInequivalentUrl()
        {
            var url1 = new Url(canonicalUrl1);
            var url2 = new Url(canonicalUrl2);

            Assert.IsFalse(url1.Equals(url2));
        }
开发者ID:candera,项目名称:tpanl,代码行数:7,代码来源:UrlTests.cs


示例10: RequestContext

        private SpiderSetting spiderSetting; //关联的Spider配置信息

        #endregion Fields

        #region Constructors

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="url">请求的Url</param>
        /// <param name="responseHeaders">HTTP响应头集合</param>
        internal RequestContext(SpiderSetting setting, Url url, HttpWebResponse response)
        {
            this.spiderSetting = setting;
            this.requestUrl = url;
            this.contentType = Content.ContentType.Unknown;
            this.contentEncoding = Encoding.Default;
            this.headers = new NameValueCollection(response.Headers);

            //从Headers[contentType]字符串,如 text/html;charset=gb2312,初始化ContentType和ContentEncoding
            StringDictionary items = Utils.DetectContentTypeHeader(response.Headers[HttpResponseHeader.ContentType]);
            this.mime = items["mime"] == null ? "" : items["mime"];
            this.charset = items["charset"] == null ? "" : items["charset"];

            if (this.mime.StartsWith("text/") || this.mime == "application/x-javascript")
            {
                this.contentType = Content.ContentType.Text;
            }
            else
            {
                this.contentType = Content.ContentType.Binary;
            }

            if (this.charset == "")
            {
                this.contentEncoding = Encoding.Default;
            }
            else
            {
                this.contentEncoding = Encoding.GetEncoding(this.charset);
            }
        }
开发者ID:erpframework,项目名称:spiderframework,代码行数:42,代码来源:RequestContext.cs


示例11: GetStaticMap

        /// <summary>
        /// Generates a map Uri for the given map details
        /// </summary>
        /// <param name="mapDetails"></param>
        /// <returns>Uri of a map image</returns>
        public Uri GetStaticMap(MapDetails mapDetails)
        {
            if (mapDetails == null) throw new ArgumentNullException(nameof(mapDetails));

            var url = new Url(GoogleMapsEndPoint);

            url.SetQueryParam("size", $"{mapDetails.Width}x{mapDetails.Height}");

            if (string.IsNullOrEmpty(mapDetails.EncodedPolyline))
            {
                if(mapDetails.Center != null)
                {
                    url.SetQueryParam("center",
                        $"{mapDetails.Center.Latitude},{mapDetails.Center.Longitude}");
                }

                url.SetQueryParam("zoom", ConvertZoomToRange(mapDetails.Zoom).ToString());
            }
            else
            {
                url.SetQueryParam("path", "enc:" + mapDetails.EncodedPolyline);
            }

            return new Uri(url, UriKind.Absolute);
        }
开发者ID:olevett,项目名称:staticmaps,代码行数:30,代码来源:GoogleMapsProvider.cs


示例12: Url_UnknownProtocol

		public void Url_UnknownProtocol () 
		{
			string url = "mono://www.go-mono.com";
			Url u = new Url (url);
			// Fx 2.0 returns the original url, while 1.0/1.1 adds a '/' at it's end
			Assert.IsTrue (u.Value.StartsWith (url), "mono.Value");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:UrlTest.cs


示例13: InitQueues

        /**
         * init the queues which will be used as link points between the threads
         */
        protected static void InitQueues(String taskId)
        {
            System.Console.Write("$$$ Initalizing Requests .. ");
            _serversQueues = new List<Queue<Url>>();
            _feedBackQueue = new Queue<Url>();

            for (int serverNum = 0; serverNum < _numWorkers; serverNum++)
            {
                _serversQueues.Add(new Queue<Url>());
            }

            // getting seeds
            if (_operationMode == operationMode_t.Manual)
            {
                foreach (string url in _seedList)
                {
                    Url task = new Url(url, 0, 100, url, 0);
                    _feedBackQueue.Enqueue(task);
                }
            }
            else if (_operationMode == operationMode_t.Auto)
            {
                List<String> seeds = StorageSystem.StorageSystem.getInstance().getSeedList(taskId);
                foreach (string url in seeds)
                {
                    Url task = new Url(url.Trim(), 0, 100, url.Trim(), 0);
                    _feedBackQueue.Enqueue(task);
                    //System.Console.WriteLine("SEED: " + url);
                }
            }
            System.Console.WriteLine("SUCCESS");
        }
开发者ID:eumagnun,项目名称:iwebcrawler,代码行数:35,代码来源:Crawler.cs


示例14: CollectionChangedReplaceDataItemsResultInCollectionChangedForAdapter

        public void CollectionChangedReplaceDataItemsResultInCollectionChangedForAdapter()
        {
            //create a list of dataItem containing urls
            IEventedList<IDataItem> dataItems = new EventedList<IDataItem>();
            var oldUrl = new Url();
            var newUrl = new Url();
            var dataItem = new DataItem(oldUrl);
            dataItems.Add(dataItem);

            //adapter for the list
            var adapter = new DataItemListAdapter<Url>(dataItems);

            int callCount = 0;
            adapter.CollectionChanged += (sender, e) =>
            {
                callCount++;
                Assert.AreEqual(NotifyCollectionChangedAction.Replace,e.Action);
                Assert.AreEqual(adapter, sender);
                Assert.AreEqual(newUrl, e.Item);
                //discutable but current eventedlist implementation does this
                Assert.AreEqual(-1, e.OldIndex);
                Assert.AreEqual(0, e.Index);
            };

            //action! replace one dataitem with another
            dataItems[0] = new DataItem(newUrl);
            Assert.AreEqual(1, callCount);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:28,代码来源:DataItemListAdapterTest.cs


示例15: Add

        public Url Add(string longUrl, string id = null, ObjectId userId = default(ObjectId))
        {
            var url = new Url
            {
                LongUrl = longUrl,
                Id = id,
                UserId = userId,
                Created = DateTime.UtcNow,
                ClickCount = 0
            };

            // Normalize and validate long URL
            url.LongUrl = new UrlNormalizer().Normalize(url.LongUrl);
            if (url.LongUrl == null) throw new InvalidUrlException(url.LongUrl);

            // Generate or validate short ID
            if (url.Id == null)
            {
                url.Id = _idGenerator.Generate();
            }
            else
            {
                if (_idGenerator.IsTaken(url.Id))
                {
                    throw new IdAlreadyTakenException(url.Id);
                }
            }

            DB.Urls.Insert(url, SafeMode.FSyncTrue);
            return url;
        }
开发者ID:lgadi,项目名称:ZeeBi,代码行数:31,代码来源:UrlsRepository.cs


示例16: CreateNancyRequest

        private static Request CreateNancyRequest(HttpContextBase context)
        {
            var expectedRequestLength =
                GetExpectedRequestLength(context.Request.Headers.ToDictionary());

            var basePath = context.Request.ApplicationPath;

            var path = context.Request.Url.AbsolutePath.Substring(basePath.Length);
            path = string.IsNullOrWhiteSpace(path) ? "/" : path;

            var nancyUrl = new Url
                               {
                                   Scheme = context.Request.Url.Scheme,
                                   HostName = context.Request.Url.Host,
                                   Port = context.Request.Url.Port,
                                   BasePath = basePath,
                                   Path = path,
                                   Query = context.Request.Url.Query,
                                   Fragment = context.Request.Url.Fragment,
                               };

            return new Request(
                context.Request.HttpMethod.ToUpperInvariant(),
                nancyUrl,
                RequestStream.FromStream(context.Request.InputStream, expectedRequestLength, true),
                context.Request.Headers.ToDictionary(),
                context.Request.UserHostAddress);
        }
开发者ID:rstat1,项目名称:Nancy,代码行数:28,代码来源:NancyHandler.cs


示例17: OriginOfGitHubAddressShouldBeGitHubCom

 public void OriginOfGitHubAddressShouldBeGitHubCom()
 {
     var address = "https://github.com/FlorianRappl/AngleSharp";
     var result = new Url(address);
     Assert.IsFalse(result.IsInvalid);
     Assert.AreEqual("https://github.com", result.Origin);
 }
开发者ID:fjwuyongzhi,项目名称:AngleSharp,代码行数:7,代码来源:Url.cs


示例18: gravahtml

        private bool gravahtml(Url u)
        {
            try
            {

                string path = "";
                byte[] stream = new System.Text.UTF8Encoding(true).GetBytes(u.getCode());
                FileStream fp;
                if ((u.getPasta() != null) && (u.getPasta().Length > 0))
                {
                    criaestrutura(u.getDominio() + "/" + u.getPasta());
                    path = u.getDominio() + "\\" + u.getPasta().Replace('/', '\\') + "\\" + u.getFicheiro();
                    path = path.Replace('?', '-');
                    fp = File.Create(directorio + path);
                    fp.Write(stream, 0, stream.Length);
                    if (fp != null) resultado = true;
                    fp.Close();
                }
                else
                {
                    criaestrutura(u.getDominio());
                    fp = File.Create(directorio + u.getDominio() + "\\" + u.getFicheiro());
                    fp.Write(stream, 0, stream.Length);
                    if (fp != null) resultado = true;
                    fp.Close();
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:ggsamsa,项目名称:webfolder,代码行数:33,代码来源:MyGravar.cs


示例19: CreateDomain

        /// <summary>
        /// Construct an application domain for running a test package
        /// </summary>
        /// <param name="package">The TestPackage to be run</param>
        public AppDomain CreateDomain( TestPackage package )
        {
            AppDomainSetup setup = CreateAppDomainSetup(package);

            string domainName = "test-domain-" + package.Name;
            // Setup the Evidence
            Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
            if (evidence.Count == 0)
            {
                Zone zone = new Zone(SecurityZone.MyComputer);
                evidence.AddHost(zone);
                Assembly assembly = Assembly.GetExecutingAssembly();
                Url url = new Url(assembly.CodeBase);
                evidence.AddHost(url);
                Hash hash = new Hash(assembly);
                evidence.AddHost(hash);
            }

            log.Info("Creating AppDomain " + domainName);

            AppDomain runnerDomain = AppDomain.CreateDomain(domainName, evidence, setup);

            // Set PrincipalPolicy for the domain if called for in the settings
            if (_settingsService != null && _settingsService.GetSetting("Options.TestLoader.SetPrincipalPolicy", false))
            {
                runnerDomain.SetPrincipalPolicy(_settingsService.GetSetting(
                    "Options.TestLoader.PrincipalPolicy", 
                    PrincipalPolicy.UnauthenticatedPrincipal));
            }

            return runnerDomain;
        }
开发者ID:alfeg,项目名称:nunit,代码行数:36,代码来源:DomainManager.cs


示例20: execute0

 public override bool execute0(Url u)
 {
     if ((u.gettipo()) != base.GetTipo())
         return true;
     else
         return false;
 }
开发者ID:ggsamsa,项目名称:webfolder,代码行数:7,代码来源:FiltroTipoDiferente.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UrlBuilder类代码示例发布时间:2022-05-24
下一篇:
C# UriTemplate类代码示例发布时间: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