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


C# Uri.LastIndexOf方法代码示例

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


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

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

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

示例3: generateLocalEpisodeFileName

        private string generateLocalEpisodeFileName(PodcastEpisodeModel podcastEpisode)
        {
            // Parse the filename of the logo from the remote URL.
            string localPath = new Uri(podcastEpisode.EpisodeDownloadUri).LocalPath;
            string podcastEpisodeFilename = localPath.Substring(localPath.LastIndexOf('/') + 1);

            podcastEpisodeFilename = PodcastSubscriptionsManager.sanitizeFilename(podcastEpisodeFilename);
            podcastEpisodeFilename = String.Format("{0}_{1}", DateTime.Now.Millisecond, podcastEpisodeFilename);

            string localPodcastEpisodeFilename = App.PODCAST_DL_DIR + "/" + podcastEpisodeFilename;
            Debug.WriteLine("Found episode filename: " + localPodcastEpisodeFilename);

            return localPodcastEpisodeFilename;
        }
开发者ID:kypeli,项目名称:Podcatcher,代码行数:14,代码来源:PodcastEpisodesDownloadManager.cs

示例4: GetAcceptedTypes

		private MimeType[] GetAcceptedTypes(MimeTypes registeredMimes)
		{
			var mimeTypes = new List<MimeType>();
			var originalUrl = Request.Uri.GetLeftPart(UriPartial.Authority) + Request.Url;
			var lastSegment = new Uri(originalUrl).Segments.Last();
			
			if (lastSegment.Contains(".") && (lastSegment.LastIndexOf(".") < lastSegment.Length - 1))
			{
				var extension = lastSegment.Substring(lastSegment.LastIndexOf(".") + 1);
				var mimeType = registeredMimes.GetMimeTypeForExtension(extension);

				if (mimeType != null)
					mimeTypes.Add(mimeType);
			}

			mimeTypes.AddRange(AcceptType.Parse(AcceptHeader, registeredMimes));			
			
			return mimeTypes.Distinct().ToArray();
		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:19,代码来源:RestfulController.cs

示例5: MetaGenerator

        public ActionResult MetaGenerator(string domain, string page)
        {
            domain = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port).ToLower();

            var host = new System.Uri(domain).Host;
            int index = host.LastIndexOf('.'), last = 3;
            while (index > 0 && index >= last - 3)
            {
                last = index;
                index = host.LastIndexOf('.', last - 1);
            }

            var res = host.Substring(index + 1);

            res = "~/Views/Shared/" + (res == "localhost" ? "gestionestampa.com" : res);

            try
            {
                TempData["MetaTitle"] = HttpContext.GetLocalResourceObject(res, page.ToLower() + "Title") + " - PapiroStar ";
                TempData["MetaDescription"] = HttpContext.GetLocalResourceObject(res, page.ToLower() + "Description");
                TempData["MetaKeyword"] = HttpContext.GetLocalResourceObject(res, page.ToLower() + "Keyword");
                TempData["MetaRobots"] = HttpContext.GetLocalResourceObject(res, page.ToLower() + "Robots") == null ? "index,follow" : HttpContext.GetLocalResourceObject(res, page.ToLower() + "Robots");
            }
            catch (Exception)
            {
                TempData["MetaTitle"] = "PapiroStar";
                TempData["MetaDescription"] = "";
                TempData["MetaKeyword"] = "";
                TempData["MetaRobots"] = "noindex, nofollow";
            }
            return null;
        }
开发者ID:algola,项目名称:backup,代码行数:32,代码来源:ControllerBase.cs

示例6: AddFromUrl

        private async Task AddFromUrl(string url)
        {
            var uriDrag = new Uri(url).AbsolutePath;
            var jiraRef = uriDrag.Substring(uriDrag.LastIndexOf("/") + 1);
            var todaysDate = DateTime.Now.Date;
            var dayTimers = ModelHelpers.Gallifrey.JiraTimerCollection.GetTimersForADate(todaysDate).ToList();

            if (dayTimers.Any(x => x.JiraReference == jiraRef))
            {
                ModelHelpers.Gallifrey.JiraTimerCollection.StartTimer(dayTimers.First(x => x.JiraReference == jiraRef).UniqueId);
                ModelHelpers.RefreshModel();
                ModelHelpers.SelectRunningTimer();
            }
            else
            {
                //Validate jira is real
                try
                {
                    ModelHelpers.Gallifrey.JiraConnection.GetJiraIssue(jiraRef);
                }
                catch (NoResultsFoundException)
                {
                    await DialogCoordinator.Instance.ShowMessageAsync(ModelHelpers.DialogContext, "Invalid Jira", $"Unable To Locate That Jira.\n\nJira Ref Dropped: '{jiraRef}'");
                    return;
                }

                //show add form, we know it's a real jira & valid
                var addTimer = new AddTimer(ModelHelpers, startDate: todaysDate, jiraRef: jiraRef, startNow: true);
                await ModelHelpers.OpenFlyout(addTimer);
                if (addTimer.AddedTimer)
                {
                    ModelHelpers.SetSelectedTimer(addTimer.NewTimerId);
                }
            }
        }
开发者ID:BlythMeister,项目名称:Gallifrey,代码行数:35,代码来源:TimerTabs.xaml.cs

示例7: LostPassword

        public ActionResult LostPassword(UserLostPasswordForm input)
        {
            var status = ModelState.IsValid ? LostPassworsStatus.Send : LostPassworsStatus.Error;
            if (status == LostPassworsStatus.Error)
            {
                var error = new { Status = status };
                return Json(error, JsonRequestBehavior.AllowGet);
            }

            var user = _repositoryCommerce.GetUserByEmail(input.Email);
            if (user == null)
            {
                ModelState.AddModelError("email", "E-mail não cadastrado");
                status = LostPassworsStatus.InvalidEmail;
            }

            if (ModelState.IsValid)
            {
                var guid = Guid.NewGuid().ToString("N");
                var dateLimit = DateTime.Now.AddDays(2);

                var originalPath = new Uri(System.Web.HttpContext.Current.Request.Url.AbsoluteUri).OriginalString;
                var parentDirectory = originalPath.Substring(0, originalPath.LastIndexOf("/", StringComparison.Ordinal));
                var guidLink = string.Concat(parentDirectory, "/RecoveryPassword?guid=", guid);

                try
                {
                    if (!_mailProvider.SendEmailLostPassword(user, guidLink)) throw new Exception("Error to sent email");

                    user.LostPasswordGuid = guid;
                    user.LostPasswordDateLimit = dateLimit;
                    _repositoryCommerce.CommitChanges();
                }
                catch (Exception)
                {
                    status = LostPassworsStatus.ErrorSendEmail;
                }
            }

            var returnValue = new { Status = status };
            return Json(returnValue, JsonRequestBehavior.AllowGet);
        }
开发者ID:igorquintaes,项目名称:TibiaCommunity,代码行数:42,代码来源:UserController.cs

示例8: LoadDesignerAssembly

        private void LoadDesignerAssembly()
        {
            if (this.assembly != null && ! this.IsFrameworkAssembly())
            {
                var file = new Uri(assembly.CodeBase).AbsolutePath;
                var designerName = file.Insert(file.LastIndexOf('.'), ".design");

                try
                {
                    this.DesignerAssembly = Assembly.LoadFile(designerName);

                    // TODO: This is a hack to see if copying the assemblies to the bin folder fixes the problem of the designer failing to load an assembly.
                    this.CopyAssemblies(Assembly);
                    this.CopyAssemblies(DesignerAssembly);
                    RegisterDesigner();
                }
                catch (FileLoadException)
                {
                }
                catch (FileNotFoundException)
                {
                }
            }
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:24,代码来源:XamlClrRef.cs

示例9: tabTimerDays_DragDrop

        private void tabTimerDays_DragDrop(object sender, DragEventArgs e)
        {
            var url = GetUrl(e);
            if (!string.IsNullOrWhiteSpace(url))
            {
                var uriDrag = new Uri(url).AbsolutePath;
                var jiraRef = uriDrag.Substring(uriDrag.LastIndexOf("/") + 1);

                var selectedTabDate = GetSelectedTabDate();
                //Check if already added & if so start timer.
                if (selectedTabDate.HasValue)
                {
                    var dayTimers = gallifrey.JiraTimerCollection.GetTimersForADate(selectedTabDate.Value);
                    if (dayTimers.Any(x => x.JiraReference == jiraRef))
                    {
                        gallifrey.JiraTimerCollection.StartTimer(dayTimers.First(x => x.JiraReference == jiraRef).UniqueId);
                        RefreshInternalTimerList();
                        if (gallifrey.JiraTimerCollection.GetRunningTimerId().HasValue)
                        {
                            SelectTimer(gallifrey.JiraTimerCollection.GetRunningTimerId().Value);
                        }
                        return;
                    }
                }

                //Validate jira is real
                try
                {
                    gallifrey.JiraConnection.GetJiraIssue(jiraRef);
                }
                catch (Exception)
                {
                    MessageBox.Show(string.Format("Unable To Locate That Jira.\n\nJira Ref Dropped: '{0}'", jiraRef), "Cannot Find Jira", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //show add form, we know it's a real jira & valid

                var addForm = new AddTimerWindow(gallifrey);
                addForm.PreLoadJira(jiraRef);

                if (selectedTabDate.HasValue)
                {
                    addForm.PreLoadDate(selectedTabDate.Value, true);
                    if (selectedTabDate.Value.Date == DateTime.Now.Date)
                    {
                        addForm.PreLoadStartNow();
                    }
                }
                else
                {
                    addForm.PreLoadStartNow();
                }

                if (addForm.DisplayForm)
                {
                    addForm.ShowDialog();
                    RefreshInternalTimerList();
                    if (addForm.NewTimerId.HasValue) SelectTimer(addForm.NewTimerId.Value);
                }
            }
        }
开发者ID:richard-green,项目名称:Gallifrey,代码行数:62,代码来源:MainWindow.cs

示例10: localEpisodeFileName

        private string localEpisodeFileName(PodcastEpisodeModel podcastEpisode)
        {
            // Parse the filename of the logo from the remote URL.
            string localPath = new Uri(podcastEpisode.EpisodeDownloadUri).LocalPath;
            string podcastEpisodeFilename = localPath.Substring(localPath.LastIndexOf('/') + 1);

            string localPodcastEpisodeFilename = App.PODCAST_DL_DIR + "/" + podcastEpisodeFilename;
            Debug.WriteLine("Found episode filename: " + localPodcastEpisodeFilename);

            return localPodcastEpisodeFilename;
        }
开发者ID:aluetjen,项目名称:Podcatcher,代码行数:11,代码来源:PodcastEpisodesDownloadManager.cs

示例11: Main


//.........这里部分代码省略.........
                proj = Project.openProject(path);
            }
            catch (Exception ex)
            {
                Logger.Instance.log(Logger.LogLevel.ERROR, "Failed to open Project file:");
                Logger.Instance.log(Logger.LogLevel.CONTINUE, ex.Message);
                Logger.Instance.close();
                if (anyKey)
                {
                    Console.WriteLine("\nPress ANY key to continue");
                    Console.ReadKey();
                }
                return exitCode;
            }
            try
            {
                //ToDo: Dont pick "default" compiler and instead pick by version number (need to scan filesystem for this + have a compiler rdy for usage ...)
                string compilerPath = "";
                string compilerVersion = proj.CompilerVersion.ToString();
                if (compilerVersion == "")
                {
                    Logger.Instance.log(Logger.LogLevel.ERROR, "Compiler version of given project is either not set or empty");
                    Logger.Instance.close();
                    if (anyKey)
                    {
                        Console.WriteLine("\nPress ANY key to continue");
                        Console.ReadKey();
                    }
                    return exitCode;
                }
                if (dllPath == "")
                {
                    var executablePath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
                    executablePath = executablePath.Substring(0, executablePath.LastIndexOf('\\'));
                    foreach (var f in Directory.EnumerateFiles(executablePath))
                    {
                        if (f.Contains(compilerVersion))
                        {
                            compilerPath = f;
                            break;
                        }
                    }
                }
                else
                {
                    compilerPath = dllPath;
                }
                if (compilerPath == "")
                {
                    Logger.Instance.log(Logger.LogLevel.ERROR, "Coult not locate compiler dll with version number " + proj.CompilerVersion);
                    Logger.Instance.close();
                    if (anyKey)
                    {
                        Console.WriteLine("\nPress ANY key to continue");
                        Console.ReadKey();
                    }
                    return exitCode;
                }
                Assembly assembly = Assembly.LoadFrom(compilerPath);
                Type type = assembly.GetType("Wrapper.Compiler", true);
                compiler = (ICompiler_1)Activator.CreateInstance(type);

            }
            catch (Exception ex)
            {
                Logger.Instance.log(Logger.LogLevel.ERROR, "Failed to load compiler:");
开发者ID:chris579,项目名称:ObjectOrientedScripting,代码行数:67,代码来源:Program.cs


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