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


C# Url类代码示例

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


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


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