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