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


C# Uri.Substring方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            Console.WriteLine("ymir2xml converter by xenor");
            Console.WriteLine("Copyright (c) 2012 - All Rights reserved.");
            Console.WriteLine("-----------------------------------------");

            args = new string[] { "group.txt" };

            if (args.Length == 0)
            {
                Console.WriteLine("Drag and drop files to the executable to begin.");
            }
            else
            {
                foreach (string filename in args)
                {
                    string relFilename = filename;
                    try
                    {
                        relFilename = new Uri(System.IO.Directory.GetCurrentDirectory() + @"\").MakeRelativeUri(new Uri(filename)).ToString();
                    }
                    catch { }

                    if (relFilename.Substring(relFilename.Length - 3, 3) == "xml")
                    {
                        Console.WriteLine("parse xml file");
                        parseXML(filename);
                    }
                    else if ((relFilename.Length >= 4 && relFilename.Substring(0, 4) == "boss") || (relFilename.Length >= 3 && relFilename.Substring(0, 3) == "npc") || (relFilename.Length >= 5 && relFilename.Substring(0, 5) == "regen") || (relFilename.Length >= 5 && relFilename.Substring(0, 5) == "stone"))
                    {
                        Console.WriteLine("parse regen file");
                        parseRegenfile(filename);
                    }
                    else if (relFilename.Length >= 11 && relFilename.Substring(0, 11) == "group_group")
                    {
                        Console.WriteLine("parse group_group file");
                        parseGroupGroupfile(filename);
                    }
                    else if (relFilename.Length >= 5 && relFilename.Substring(0, 5) == "group")
                    {
                        Console.WriteLine("parse group file");
                        parseGroupfile(filename);
                    }
                    else if (relFilename.Length >= 7 && (relFilename.Substring(0, 7) == "Setting" || relFilename.Substring(0, 7) == "setting"))
                    {
                        Console.WriteLine("parse settings file");
                        parseSetting(filename);
                    }
                    else
                    {
                        Console.WriteLine(relFilename + " - Unknown filetype");
                    }
                }
            }

            Console.WriteLine("done");
            Console.ReadKey();
        }
开发者ID:xenor,项目名称:ymir2xml,代码行数:58,代码来源:Program.cs

示例2: GetMediaId

 /// <summary>
 /// 取得媒體ID
 /// </summary>
 /// <param name="Url">網址</param>
 /// <returns>媒體ID</returns>
 private string GetMediaId(string Url) {
     string result = new Uri(Url).Segments.Last<string>();
     try {
         result = result.Substring(0, result.IndexOf("_"));
     } catch { }
     return result;
 }
开发者ID:XuPeiYao,项目名称:MediaGetCore,代码行数:12,代码来源:DailymotionExtractor.cs

示例3: 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

示例4: 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

示例5: AbsolutoParaRelativo

        public static string AbsolutoParaRelativo(string de, string para, string inicio)
        {
            string path = new Uri(para).MakeRelativeUri(new Uri(de)).ToString();
            path = path.Substring(path.LastIndexOf(inicio), path.Length - path.LastIndexOf(inicio));

            return "~" + path;
        }
开发者ID:rdgsDEV,项目名称:GdS,代码行数:7,代码来源:Utilidades.cs

示例6: 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

示例7: CreateImageFolder

 public static void CreateImageFolder(this string itemName)
 {
     var path = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
     var mainPath = path.Substring(0, path.IndexOf("bin", 0));
     var imgPath = string.Format(@"{0}\Content\images\item\{1}", mainPath, itemName);
     if (!Directory.Exists(imgPath))
         Directory.CreateDirectory(imgPath);
 }
开发者ID:hakeemsm,项目名称:TheDessertHouse,代码行数:8,代码来源:Extensions.cs

示例8: BuildHost

 private string BuildHost(string website)
 {
     var host = new Uri(website, UriKind.Absolute).Host;
     if (host.Contains("www."))
     {
         host = host.Substring(4);
     }
     return host;
 }
开发者ID:ncpenn,项目名称:FindBrokenLinksCommandLine,代码行数:9,代码来源:Spider.cs

示例9: PathFromUri

        private static string PathFromUri(string uri)
        {
            string baseUri = new Uri(uri).PathAndQuery;
            if (baseUri.StartsWith("/"))
            {
                baseUri = baseUri.Substring(1);
            }

            return baseUri;
        }
开发者ID:mdabbagh88,项目名称:ODataServer,代码行数:10,代码来源:TraceController.cs

示例10: GetDomain

        private static string GetDomain(IConfiguration settings)
        {
            var domain = new Uri(settings.GetSiteRoot(false)).DnsSafeHost;

            if (domain.IndexOf(':') >= 0)
            {
                domain = domain.Substring(0, domain.IndexOf(':'));
            }

            return domain;
        }
开发者ID:chocolatey,项目名称:chocolatey.org,代码行数:11,代码来源:MessageService.cs

示例11: Compiler

 public Compiler()
 {
     configFileName = "config.cpp";
     stdLibPath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
     stdLibPath = stdLibPath.Substring(0, stdLibPath.LastIndexOf('\\')) + "\\stdLibrary\\";
     addFunctionsClass = true;
     outputFolderCleanup = true;
     printOutMode = 0;
     flagDefines = new List<PPDefine>();
     SqfCall.readSupportInfoList();
     includedFiles = new List<string>();
 }
开发者ID:chris579,项目名称:ObjectOrientedScripting,代码行数:12,代码来源:Compiler.cs

示例12: TransformRobocode

        public static void TransformRobocode()
        {
            var w = new Uri("http://robocode.sourceforge.net/docs/robocode/allclasses-noframe.html").ToWebString();

            var zip = new ZIPFile();

            var o = 0;
            while (o >= 0)
            {
                const string pregfix = "<A HREF=\"";
                var i = w.IndexOf(pregfix, o);
                if (i >= 0)
                {
                    var j = w.IndexOf("\"", i + pregfix.Length);

                    if (j >= 0)
                    {
                        var type = w.Substring(i + pregfix.Length, j - (i + pregfix.Length));

                        const string suffix = ".html";

                        if (type.EndsWith(suffix))
                        {
                            o = j + 1;

                            type = type.Substring(0, type.Length - suffix.Length).Replace("/", ".");

                            Console.WriteLine(type);

                            zip.Add(type.Replace(".", "/") + ".cs",
                                new DefinitionProvider(
                                    type
                                //        "robocode.BattleRules"
                                //        //"java.net.InetSocketAddress"
                                //        //"java.net.ServerSocket"
                                //        //"java.nio.channels.ServerSocketChannel"
                                , k => k.ToWebString()).GetString()
                            );

                        }
                        else o = -1;
                    }
                    else o = -1;
                }
                else o = -1;
            }

            using (var ww = new BinaryWriter(File.OpenWrite("Robocode.zip")))
            {
                zip.WriteTo(ww);
            }
        }
开发者ID:BGCX261,项目名称:zproxygames-svn-to-git,代码行数:52,代码来源:Setup.cs

示例13: BeforeRequest

        public bool BeforeRequest(Session session, Rule rule)
        {
            Console.WriteLine(String.Format("Request ({0}) cached due to the rule: {1}", session.hostname, rule.Name));

            // TODO:
            // Cache-Control - Expires, MaxAge (private)
            // Age?
            //
            var querystring = new Uri(session.fullUrl).Query;
            var startindex = querystring.IndexOf("&url=");
            var length = querystring.IndexOf("&ei", startindex) - startindex;
            var url = querystring.Substring(startindex, length);
            session.fullUrl = Uri.UnescapeDataString(url);

            return false;
        }
开发者ID:bradrees,项目名称:HttpRules,代码行数:16,代码来源:CacheAction.cs

示例14: FindPath

        private bool FindPath(string rawUrl, out string foundUri)
        {
            foundUri = new Uri(rawUrl, UriKind.Relative).NormalizedPathAndQuery();
            if (_contentState.Storage.ContainsKey(foundUri))
                return true;

            int pos;
            char[] args = new char[] {'?', '&'};
            while((pos = foundUri.LastIndexOfAny(args)) > 0) //not possible to find index zero, i.e. '/?'
            {
                foundUri = foundUri.Substring(0, pos);
                if (_contentState.Storage.ContainsKey(foundUri))
                    return true;
            }
            return false;
        }
开发者ID:modulexcite,项目名称:httpclone,代码行数:16,代码来源:ContentRequestHandler.cs

示例15: LoadPlaylist

 public override void LoadPlaylist(string fpath)
 {
     ItemsPaths = new ArrayList();
     //
     try
     {
         XmlReaderSettings settings = new XmlReaderSettings();
         settings.XmlResolver = null;
         settings.DtdProcessing = DtdProcessing.Ignore;
         settings.ValidationType = ValidationType.None;
         using (XmlReader reader = XmlReader.Create(fpath, settings))
         {
             CheckFileType(reader);
             while (reader.ReadToFollowing("key"))
             {
                 reader.ReadStartElement("key");
                 if (reader.ReadString().ToLower().Equals("location"))
                 {
                     reader.ReadEndElement();
                     reader.ReadStartElement("string");
                     string str = new Uri(reader.ReadString().Trim()).LocalPath;
                     if (str.StartsWith(@"\\localhost\")) str = str.Substring(12);
                     ItemsPaths.Add(str);
                     reader.ReadEndElement();
                 }
                 else
                     reader.ReadEndElement();
             }
         }
     }
     catch (IOException)
     {
         throw new Exception("Error occured during the file reading process!");
     }
     catch (XmlException)
     {
         throw new Exception("Error occured during the file parsing process!");
     }
 }
开发者ID:zitmen,项目名称:playlist-copier,代码行数:39,代码来源:XMLPlaylistParser.cs


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