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


C# Uri.EndsWith方法代码示例

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


在下文中一共展示了Uri.EndsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

        public void SetUp()
        {
            originalDirectory = Environment.CurrentDirectory;

            var root = new Uri(typeof(BuildFixture).Assembly.CodeBase).LocalPath;
            while (!root.EndsWith("source") && !root.EndsWith("source\\"))
            {
                root = Path.GetFullPath(Path.Combine(root, "..\\"));
            }

            Environment.CurrentDirectory = Path.Combine(root, "Samples");

            Clean("Sample.ConsoleApp\\bin");
            Clean("Sample.WebApp\\bin");
            Clean("Sample.WebAppWithSpec\\bin");
        }
开发者ID:jmezach,项目名称:NuGetPack,代码行数:16,代码来源:BuildFixture.cs

示例2: Main

        static void Main(string[] args)
        {
            CTHReader cth = new CTHReader();

            if (ConfigurationManager.AppSettings["passwordPrompt"] == "true")
            {
                Console.WriteLine("Please provide user name to connect to the site:");
                cth.UserName = Console.ReadLine();

                Console.WriteLine("Please provide the password:");
                cth.UserPassword = getPassword();

                Console.WriteLine();

            }
            cth.OutputFilePrefix = ConfigurationManager.AppSettings["outputFilePrefix"];

            string outputLocation = ConfigurationManager.AppSettings["outputLocation"];
            string siteUrl = new Uri(ConfigurationManager.AppSettings["siteUrl"]).ToString();

            if (siteUrl.EndsWith("/"))
            {
                siteUrl = siteUrl.Substring(0, siteUrl.Length - 1);
            }

            Console.WriteLine(cth.ProcessCTH(siteUrl, outputLocation, CTHReader.CTHQueryMode.CTHAndSiteColumns));
            //doit();
            //tidyUpXMLDoc();
            //queryXMLProcess();
        }
开发者ID:JasonGJones,项目名称:CTHReader,代码行数:30,代码来源:Program.cs

示例3: GetLayoutHtml

        public static string GetLayoutHtml(CommonViewModel model, string page, IEnumerable<string> stylesheets, IEnumerable<string> scripts)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (page == null) throw new ArgumentNullException("page");
            if (stylesheets == null) throw new ArgumentNullException("stylesheets");
            if (scripts == null) throw new ArgumentNullException("scripts");

            var applicationPath = new Uri(model.SiteUrl).AbsolutePath;
            if (applicationPath.EndsWith("/")) applicationPath = applicationPath.Substring(0, applicationPath.Length - 1);

            var pageUrl = "assets/app." + page + ".html";

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonSerializerSettings() { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() });

            var additionalStylesheets = BuildTags("<link href='{0}' rel='stylesheet'>", applicationPath, stylesheets);
            var additionalScripts = BuildTags("<script src='{0}'></script>", applicationPath, scripts);

            return LoadResourceString("Thinktecture.IdentityServer.Core.Views.Embedded.Assets.app.layout.html",
                new
                {
                    siteName = model.SiteName,
                    applicationPath,
                    pageUrl,
                    model = json,
                    stylesheets = additionalStylesheets,
                    scripts = additionalScripts
                });
        }
开发者ID:RhysC,项目名称:Thinktecture.IdentityServer.v3,代码行数:28,代码来源:AssetManager.cs

示例4: MakeURLPretty

        private string MakeURLPretty(string url)
        {
            var lowURL = url.ToLower();
            
            if (lowURL.StartsWith("http://www"))
            {
                // Everything's good.
            }
            else if (lowURL.StartsWith("http://"))
            {
                var s = url.Split(new string[] { "//" }, StringSplitOptions.None);
                url = s[0] + "//www." + s[1];
            }
            else if (lowURL.StartsWith("www"))
            {
                url = "http://" + url;
            }
            else
            {
                url = "http://www." + url;
            }

            url = new Uri(url).ToString();

            if (url.EndsWith("/"))
            {
                url = url.Substring(0, url.Length - 1);
            }

            return url;
        }
开发者ID:mbaago,项目名称:WebCrawler,代码行数:31,代码来源:PrettyURL.cs

示例5: DetergentHttpListener

        public DetergentHttpListener(
            string uriPrefix,
            string applicationPath,
            IDetergentHttpHandler detergentHttpHandler)
        {
            if (uriPrefix == null)
                throw new ArgumentNullException("uriPrefix");
            if (applicationPath == null)
                throw new ArgumentNullException("applicationPath");
            if (detergentHttpHandler == null) throw new ArgumentNullException("detergentHttpHandler");

            this.uriPrefix = uriPrefix;
            this.applicationPath = applicationPath;
            this.detergentHttpHandler = detergentHttpHandler;
            httpListener = new HttpListener();

            applicationRootUrl = new Uri(new Uri(uriPrefix), applicationPath).ToString();
            if (false == applicationRootUrl.EndsWith("/", StringComparison.OrdinalIgnoreCase))
                applicationRootUrl = applicationRootUrl + '/';

            httpListener.Prefixes.Add(applicationRootUrl);

            DumpDiagnostics();

            httpListener.Start();
            IAsyncResult result = httpListener.BeginGetContext(WebRequestCallback, httpListener);
        }
开发者ID:Ryks,项目名称:detergent,代码行数:27,代码来源:DetergentHttpListener.cs

示例6: GetBaseUrl

        public static string GetBaseUrl(this HttpRequestMessage request, string host = null)
        {
            if (host.IsMissing())
            {
                host = "https://" + request.Headers.Host;
            }

            var baseUrl = new Uri(new Uri(host), request.GetRequestContext().VirtualPathRoot).AbsoluteUri;
            if (!baseUrl.EndsWith("/")) baseUrl += "/";

            return baseUrl;
        }
开发者ID:JackBao,项目名称:Thinktecture.IdentityServer.v3,代码行数:12,代码来源:HttpRequestMessageExtensions.cs

示例7: GetBaseUrl

        public static string GetBaseUrl(this IDictionary<string, object> env, string host = null)
        {
            var ctx = new OwinContext(env);
            var request = ctx.Request;
            
            if (host.IsMissing())
            {
                host = "https://" + request.Host.Value;
            }

            var baseUrl = new Uri(new Uri(host), ctx.Request.PathBase.Value).AbsoluteUri;
            if (!baseUrl.EndsWith("/")) baseUrl += "/";

            return baseUrl;
        }
开发者ID:JaiChaturvedi,项目名称:Thinktecture.IdentityServer.v3,代码行数:15,代码来源:OwinExtensions.cs

示例8: WikiPageImplementation

        private static void WikiPageImplementation(Web web, string wikiPageLibraryName, string wikiPageName, out string wikiPageUrl, out List pageLibrary, out string newWikiPageUrl, out File currentPageFile, out string pathAndQuery)
        {
            if (string.IsNullOrEmpty(wikiPageLibraryName))
            {
                throw (wikiPageLibraryName == null)
                  ? new ArgumentNullException("wikiPageLibraryName")
                  : new ArgumentException(CoreResources.Exception_Message_EmptyString_Arg, "wikiPageLibraryName");
            }

            if (string.IsNullOrEmpty(wikiPageName))
            {
                throw (wikiPageName == null)
                  ? new ArgumentNullException("wikiPageName")
                  : new ArgumentException(CoreResources.Exception_Message_EmptyString_Arg, "wikiPageName");
            }

            wikiPageUrl = "";
            pageLibrary = web.Lists.GetByTitle(wikiPageLibraryName);
            web.Context.Load(web, w => w.Url);
            web.Context.Load(pageLibrary.RootFolder, f => f.ServerRelativeUrl);
            web.Context.ExecuteQueryRetry();

            var pageLibraryUrl = pageLibrary.RootFolder.ServerRelativeUrl;
            newWikiPageUrl = pageLibraryUrl + "/" + wikiPageName;
            currentPageFile = web.GetFileByServerRelativeUrl(newWikiPageUrl);
            web.Context.Load(currentPageFile, f => f.Exists);
            web.Context.ExecuteQueryRetry();

            pathAndQuery = new Uri(web.Url).PathAndQuery;
            if (!pathAndQuery.EndsWith("/"))
            {
                pathAndQuery = pathAndQuery + "/";
            }
        }
开发者ID:dmdj,项目名称:PnP-Sites-Core,代码行数:34,代码来源:PageExtensions.cs

示例9: CreateRepository

        /// <summary>
        /// Creates the repository.
        /// </summary>
        /// <param name="repositoryName">Name of the repository.</param>
        /// <returns></returns>
        public static string CreateRepository(string repositoryName)
        {
            var sb = new StringBuilder();

            var repoPath = HostSettingManager.Get(HostSettingNames.RepositoryRootPath) + repositoryName;

            var repoCheckoutPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) +
                Path.DirectorySeparatorChar + Guid.NewGuid().ToString();

            var repoUrl = new Uri(repoPath).AbsoluteUri;

            if (!repoUrl.EndsWith("/"))
                repoUrl += "/";

            try
            {

                Directory.CreateDirectory(repoPath);
                Directory.CreateDirectory(repoCheckoutPath);

                sb.AppendLine(RunCommand("svnadmin", "create \"" + repoPath + "\""));

                sb.AppendLine(RunCommand("svn", "mkdir \"" + repoUrl + "trunk\" \"" +
                    repoUrl + "branches\" \"" + repoUrl + "tags\" \"" + repoUrl + "trunk/doc\" \"" +
                    repoUrl + "trunk/src\" -m \"Creating initial directories\""));
                sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "checkout \"" + repoUrl + "\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                // Add Issue tracker properties
                var url = HostSettingManager.Get(HostSettingNames.DefaultUrl).Trim();
                if (!url.EndsWith("/"))
                    url += "/";

                //\[?([A-Za-z]{3}-\d+)[\]:]{0,2}(\s((resolved)[,\s]+(fixed|invalid)?)|\s+(open|in progress)?)?
                //this regex locks up TortoiseSVN

                sb.AppendLine(RunCommand("svn", "propset -R bugtraq:logregex \"\\[?([A-Za-z]{3}-\\d+)\\]?.+\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "propset -R bugtraq:label \"Issue Tracker Id:\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "propset -R bugtraq:url \"" + url + "Issues/IssueDetail.aspx?id=%BUGID%\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                //sb.AppendLine(RunCommand("svn", "propset -R bugtraq:message \"Issue Tracker Id: %BUGID%\" \"" + repoCheckoutPath + "\""));
                //sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "propset -R bugtraq:number \"false\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "propset -R bugtraq:warnifnoissue \"false\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "propset -R bugtraq:append \"false\" \"" + repoCheckoutPath + "\""));
                sb.AppendLine();

                sb.AppendLine(RunCommand("svn", "commit -m \"Added Issue Tracker properties to the repository\" \"" + repoCheckoutPath + "\""));

                // Add post-commit for the integration.

                if (!repoPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
                    repoPath += Path.DirectorySeparatorChar;

                if (!String.IsNullOrEmpty(HostSettingManager.Get(HostSettingNames.SvnHookPath)))
                {
                    using (var sw = File.CreateText(repoPath + "hooks" + Path.DirectorySeparatorChar + "post-commit.bat"))
                        sw.WriteLine(HostSettingManager.Get(HostSettingNames.SvnHookPath) + @" post-commit %1 %2");
                }

                return sb.ToString();

            }
            catch (Exception ex)
            {
                if (Log.IsErrorEnabled)
                    Log.Error("Subversion Repository Creation Error", ex); //TOOD: Localize

                throw;
            }
            finally
            {
                DeleteDirectory(repoCheckoutPath);
            }
        }
开发者ID:chad247,项目名称:bugnet,代码行数:92,代码来源:SourceIntegrationManager.cs

示例10: Execute

        /// <summary>
        /// Adds the template reference to the IAssetReferenceService
        /// </summary>
        public override void Execute()
        {
            EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
            IAssetReferenceService referenceService = (IAssetReferenceService)GetService(typeof(IAssetReferenceService));
            object item = DteHelper.GetTarget(dte);



            if (item == null)
            {
                MessageBox.Show("There is no valid target to reference the template");
                return;
            }
            templateFilename = new Uri(templateFilename).LocalPath;

            VsBoundReference vsTarget = null;
            if (item is Project)
            {
                vsTarget = new ProjectReference(templateFilename, (Project)item);
            }
            else if (item is Solution)
            {
                vsTarget = new SolutionReference(templateFilename, (Solution)item);
            }
            else if (item is ProjectItem)
            {
                vsTarget = new ProjectItemReference(templateFilename, (ProjectItem)item);
            }
            else if (item is EnvDTE80.SolutionFolder)
            {
                vsTarget = new ProjectReference(templateFilename, ((EnvDTE80.SolutionFolder)item).Parent);
            }
            if (item == null || vsTarget == null)
            {
                MessageBox.Show(string.Format(
                    CultureInfo.CurrentCulture,
                    "Target {0} specified for reference to asset {1} doesn't exist.",
                    "target", templateFilename));
                return;
            }
            if (!File.Exists(templateFilename) || !templateFilename.EndsWith(".vstemplate", StringComparison.InvariantCultureIgnoreCase))
            {
                MessageBox.Show(string.Format(
                    CultureInfo.CurrentCulture,
                    "The filename specified for the template \"{0}\" does not exist.",
                    templateFilename));
                return;
            }
            newReference = new BoundTemplateReference(templateFilename, vsTarget);
            referenceService.Add(newReference);
            MessageBox.Show("The new reference was successfully added", "New Reference",
                MessageBoxButtons.OK, MessageBoxIcon.Information);

        }
开发者ID:Pelsoft,项目名称:fwk_10.3,代码行数:57,代码来源:AddItemFromString.cs

示例11: NormalizeDirectoryPath

 /// <summary>
 /// Returns absolute path of a given directory, always
 /// ending with '/'.
 /// </summary>
 public static string NormalizeDirectoryPath(string path)
 {
     string absPath = new Uri(path).LocalPath;
     if (!absPath.EndsWith("\\")) {
         absPath += "\\";
     }
     return absPath;
 }
开发者ID:TerabyteX,项目名称:main,代码行数:12,代码来源:CommonUtils.cs

示例12: CanCheck

 /// <summary>
 /// Determines whether this instance can check the availability of the link on the specified service.
 /// </summary>
 /// <param name="url">The link to check.</param>
 /// <returns>
 ///   <c>true</c> if this instance can check the specified service; otherwise, <c>false</c>.
 /// </returns>
 public override bool CanCheck(string url)
 {
     var host = new Uri(url).Host;
     return host.EndsWith("ul.to") || host.EndsWith("uploaded.to");
 }
开发者ID:troyb30,项目名称:RS-TV-Show-Tracker,代码行数:12,代码来源:Uploadedto.cs

示例13: IsWhitelisted

        private bool IsWhitelisted(RemoteRequestEventArgs request)
        {
            var rr = c.getNode("remotereader");
            var domain = new Uri(request.RemoteUrl).Host;
            if (rr == null || string.IsNullOrEmpty(domain)) return false;

            foreach (Node n in rr.childrenByName("allow")) {
                bool onlyWhenSigned = NameValueCollectionExtensions.Get(n.Attrs, "onlyWhenSigned", false);
                if (onlyWhenSigned && !request.SignedRequest) continue;

                bool hostMatches = false, regexMatches = false;
                string host = n.Attrs.Get("domain");
                if (!string.IsNullOrEmpty(host)) {
                    if (host.StartsWith("*.", StringComparison.OrdinalIgnoreCase))
                        hostMatches = domain.EndsWith(host.Substring(1), StringComparison.OrdinalIgnoreCase);
                    else
                        hostMatches = domain.Equals(host, StringComparison.OrdinalIgnoreCase);

                    if (!hostMatches) continue;//If any filter doesn't match, skip rule
                }

                string regex = n.Attrs.Get("regex");
                if (!string.IsNullOrEmpty(regex)) {
                    var r = new Regex("^" + regex + "$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    regexMatches = r.IsMatch(request.RemoteUrl);
                    if (!regexMatches) continue;//If any filter doesn't match, skip rule
                }
                //If all specified filters match, allow the request.
                //This *is* supposed to be || not &&, because we already deal with non-matching filters via 'continue'.
                if (hostMatches || regexMatches) return true;

            }
            return false;
        }
开发者ID:eakova,项目名称:resizer,代码行数:34,代码来源:RemoteReaderPlugin.cs

示例14: GetRootUrl

 /// <summary>
 /// Returns the correct root url
 /// </summary>
 /// <param name="req"></param>
 /// <param name="apiName"></param>
 /// <param name="apiVersion"></param>
 /// <returns></returns>
 protected static string GetRootUrl(HttpRequestMessage req, string apiName, string apiVersion)
 {
     var url = new Uri(req.RequestUri, req.GetRequestContext().VirtualPathRoot).ToString();
     url = url.EndsWith("/") ? url.Substring(0, url.Length - 1) : url;
     return url;
 }
开发者ID:WIBORI,项目名称:api-template,代码行数:13,代码来源:SwaggerConfig.cs

示例15: BuildModel

        /// <summary>
        /// Builds the model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="page">The page.</param>
        /// <param name="stylesheets">The stylesheets.</param>
        /// <param name="scripts">The scripts.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// model
        /// or
        /// stylesheets
        /// or
        /// scripts
        /// </exception>
        protected object BuildModel(CommonViewModel model, string page, IEnumerable<string> stylesheets, IEnumerable<string> scripts)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (stylesheets == null) throw new ArgumentNullException("stylesheets");
            if (scripts == null) throw new ArgumentNullException("scripts");
            
            var applicationPath = new Uri(model.SiteUrl).AbsolutePath;
            if (applicationPath.EndsWith("/")) applicationPath = applicationPath.Substring(0, applicationPath.Length - 1);

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Newtonsoft.Json.Formatting.None, settings);

            var additionalStylesheets = BuildTags("<link href='{0}' rel='stylesheet'>", applicationPath, stylesheets);
            var additionalScripts = BuildTags("<script src='{0}'></script>", applicationPath, scripts);

            return new {
                siteName = Microsoft.Security.Application.Encoder.HtmlEncode(model.SiteName),
                applicationPath,
                model = Microsoft.Security.Application.Encoder.HtmlEncode(json),
                page,
                stylesheets = additionalStylesheets,
                scripts = additionalScripts
            };
        }
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:38,代码来源:DefaultViewService.cs


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