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


C# Uri.Replace方法代码示例

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


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

示例1: GetAttachmentUri

        /// <summary>
        /// Get the URI of an attachment view
        /// </summary>
        /// <param name="attachmentId"></param>
        /// <param name="viewId">default is "original"</param>
        /// <returns>uri</returns>
        public string GetAttachmentUri(string attachmentId, string viewId = "original")
        {
            if (attachmentId == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "attachmentId");
            }

            // Construct URL
            var _baseUrl = this.Client.BaseUri.AbsoluteUri;
            var url = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "v3/attachments/{attachmentId}/views/{viewId}").ToString();
            url = url.Replace("{attachmentId}", Uri.EscapeDataString(attachmentId));
            url = url.Replace("{vieWId}", Uri.EscapeDataString(viewId));
            return url;
        }
开发者ID:CHENShuang1994,项目名称:BotBuilder,代码行数:20,代码来源:AttachmentsEx.cs

示例2: ResolveAssemblyDirectory

        private IList<string> ResolveAssemblyDirectory(Assembly assembly)
        {
            var fullUriPath = new Uri(assembly.GetName().CodeBase).LocalPath.ToUpper();
            var pathWithoutUnityFolder = fullUriPath.Replace(assembly.ManifestModule.Name.ToUpper(), "");
            var path = pathWithoutUnityFolder + @"Unity";

            if (!Directory.Exists(path)) return null;

            var files = Directory.GetFiles(path);
            return files;
        }
开发者ID:wil2200,项目名称:sdk,代码行数:11,代码来源:FileRegisteringModuleExecutor.cs

示例3: AutoConf

 public void AutoConf()
 {
     PayloadDescription desc = new PayloadDescription();
     string assembly=Assembly.GetExecutingAssembly().CodeBase;
     if (Uri.IsWellFormedUriString(assembly,UriKind.Absolute))
     {
         assembly = new Uri(assembly).AbsolutePath;
         assembly = assembly.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
     }
     desc.AssemblyFullName = Path.GetFileName(assembly);
     desc.Class = typeof(HostTest).FullName;
     Assert.AreEqual(assembly+".config", desc.ConfigurationFile, "Config file should match default name");
     Assert.AreEqual(Path.GetDirectoryName(assembly), desc.BinaryFolder, "binary folder should be assembly folder");
 }
开发者ID:dupdob,项目名称:SHON,代码行数:14,代码来源:DescriptionTests.cs

示例4: GetVimeoData

        /// <summary>
        /// Our site wide search action method
        /// </summary>
        public JsonResult GetVimeoData(string vimeoUrl)
        {
            if (!vimeoUrl.StartsWith("http://www.vimeo.com/") && !vimeoUrl.StartsWith("http://vimeo.com/"))
            {
                throw new Exception("Not a valid vimeo url");
            }

            //http://www.vimeo.com/20278551?ab = /20278551
            var videoUriWithoutQuery = new Uri(vimeoUrl).AbsolutePath;

            var videoID = videoUriWithoutQuery.Replace("/","");

            var vimeoData = new MediaService().GetVimeoVideoData(videoID);

            return Json(vimeoData);
        }
开发者ID:jkresner,项目名称:Climbfind_v4_2011,代码行数:19,代码来源:_UtilityController.cs

示例5: ExecuteCommand

		internal static void ExecuteCommand (IProgressStatus monitor, string registryPath, string startupDir, string name, params string[] args)
		{
			string asm = new Uri (typeof(SetupProcess).Assembly.CodeBase).LocalPath;
			string verboseParam = monitor.LogLevel.ToString ();
			
			// Arguments string
			StringBuilder sb = new StringBuilder ();
			sb.Append (verboseParam).Append (' ').Append (name);
			foreach (string arg in args)
				sb.Append (" \"").Append (arg).Append ("\"");
			
			Process process = new Process ();
			if (Util.IsWindows)
				process.StartInfo = new ProcessStartInfo (asm, sb.ToString ());
			else {
				asm = asm.Replace(" ", @"\ ");
				process.StartInfo = new ProcessStartInfo ("mono", "--debug " + asm + " " + sb.ToString ());
			}
			process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.RedirectStandardInput = true;
			process.StartInfo.RedirectStandardOutput = true;
			process.StartInfo.RedirectStandardError = true;
			process.EnableRaisingEvents = true;
			try {
				process.Start ();
			} catch (Exception ex) {
				Console.WriteLine (ex);
				throw;
			}
			
			process.StandardInput.WriteLine (registryPath);
			process.StandardInput.WriteLine (startupDir);
			process.StandardInput.Flush ();

//			string rr = process.StandardOutput.ReadToEnd ();
//			Console.WriteLine (rr);
			
			StringCollection progessLog = new StringCollection ();
			ProcessProgressStatus.MonitorProcessStatus (monitor, process.StandardOutput, progessLog);
			process.WaitForExit ();
			if (process.ExitCode != 0)
				throw new ProcessFailedException (progessLog);
		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:44,代码来源:SetupProcess.cs

示例6: ParseQueryString

        /// <summary>
        /// Get a Url's parameters leaving them url encoded
        /// </summary>
        /// <param name="urlString">The query string</param>
        /// <returns></returns>
        public static Dictionary<string, string> ParseQueryString(string urlString)
        {
            string queryString = new Uri(urlString).Query;
            Dictionary<string, string> kVParms = new Dictionary<string, string>();

            queryString.Replace("?", "");

            string[] keyValPairing = queryString.Split('&', '=');

            if ((keyValPairing.Length == 0) || (keyValPairing.Length % 2 != 0))
            {
                throw new Exception("Invalid input Url");
            }

            keyValPairing[0] = keyValPairing[0].TrimStart('?');

            for (int i = 0; i < keyValPairing.Length - 1; i++)
            {
                kVParms.Add(keyValPairing[i], keyValPairing[i + 1]);
            }

            return kVParms;
        }
开发者ID:Archetype,项目名称:TwitterPostWP7,代码行数:28,代码来源:Helpers.cs

示例7: RemoveDuplicateSlashes

 private static string RemoveDuplicateSlashes(string url)
 {
     var path = new Uri(url).AbsolutePath;
     return path.Contains("//") ? url.Replace(path, path.Replace("//", "/")) : url;
 }
开发者ID:rabbal,项目名称:Mvc5,代码行数:5,代码来源:NormalizationUrl.cs

示例8: FromUri

        /// <summary>
        /// Create a new SourceLineNumberCollection from a URI.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <returns>The new SourceLineNumberCollection.</returns>
        public static SourceLineNumberCollection FromUri(string uri)
        {
            if (null == uri || 0 == uri.Length)
            {
                return null;
            }

            string localPath = new Uri(uri).LocalPath;

            // make the local path really look like a normal local path
            if (localPath.StartsWith(Path.AltDirectorySeparatorChar.ToString(), StringComparison.Ordinal))
            {
                localPath = localPath.Substring(1);
            }
            localPath = localPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

            return new SourceLineNumberCollection(localPath);
        }
开发者ID:bullshock29,项目名称:Wix3.6Toolset,代码行数:23,代码来源:SourceLineNumberCollection.cs

示例9: GetUncFileName

 private static string GetUncFileName(string song)
 {
     string uncFilePath = new Uri(song).LocalPath;
     uncFilePath = uncFilePath.Replace("\\\\localhost\\", " ").Trim();
     return uncFilePath;
 }
开发者ID:xantilas,项目名称:ghalager-videobrowser-20120129,代码行数:6,代码来源:iTunesLibrary.cs

示例10: ResolveUrl

        /// <summary>
        /// fully resolves any relative pathing inside the URL, and other URL oddities
        /// </summary>
        string ResolveUrl(string url)
        {
            // resolve any relative pathing
            try
            {
                url = new Uri(url).AbsoluteUri;
            }
            catch (UriFormatException ex)
            {
                throw new ArgumentException("'" + url + "' does not appear to be a valid URL.", ex);
            }

            // remove any anchor tags from the end of URLs
            if (url.IndexOf("#") > -1)
            {
                string jump = Regex.Match(url, "/[^/]*?(?<jump>#[^/?.]+$)").Groups["jump"].Value;
                if (jump != "")
                    url = url.Replace(jump, "");
            }

            return url;
        }
开发者ID:bittercoder,项目名称:reportingcloud,代码行数:25,代码来源:MhtWebFile.cs

示例11: GeneratevpnclientpackageWithHttpMessagesAsync

        /// <summary>
        /// The Generatevpnclientpackage operation generates Vpn client package for
        /// P2S client of the virtual network gateway in the specified resource group
        /// through Network resource provider.
        /// </summary>
        /// <param name='resourceGroupName'>
        /// The name of the resource group.
        /// </param>
        /// <param name='virtualNetworkGatewayName'>
        /// The name of the virtual network gateway.
        /// </param>
        /// <param name='parameters'>
        /// Parameters supplied to the Begin Generating  Virtual Network Gateway Vpn
        /// client package operation through Network resource provider.
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public async Task<AzureOperationResponse<string>> GeneratevpnclientpackageWithHttpMessagesAsync(string resourceGroupName, string virtualNetworkGatewayName,
            VpnClientParameters parameters, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            #region 1. Send Async request to generate vpn client package

            // 1. Send Async request to generate vpn client package          
            string baseUrl = NetworkManagementClient.BaseUri.ToString();
            string apiVersion = NetworkManagementClient.ApiVersion;

            if (resourceGroupName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName");
            }
            if (virtualNetworkGatewayName == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "virtualNetworkGatewayName");
            }
            if (parameters == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "parameters");
            }

            // Construct URL
            var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/" +
                "providers/Microsoft.Network/virtualnetworkgateways/{virtualNetworkGatewayName}/generatevpnclientpackage").ToString();
            url = url.Replace("{resourceGroupName}", Uri.EscapeDataString(resourceGroupName));
            url = url.Replace("{virtualNetworkGatewayName}", Uri.EscapeDataString(virtualNetworkGatewayName));
            url = url.Replace("{subscriptionId}", Uri.EscapeDataString(NetworkManagementClient.SubscriptionId));
            url += "?" + string.Join("&", string.Format("api-version={0}", Uri.EscapeDataString(apiVersion)));

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = new HttpRequestMessage();
            httpRequest.Method = new HttpMethod("POST");
            httpRequest.RequestUri = new Uri(url);
            // Set Headers
            httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString());

            // Serialize Request
            string requestContent = JsonConvert.SerializeObject(parameters, NetworkManagementClient.SerializationSettings);
            httpRequest.Content = new StringContent(requestContent, Encoding.UTF8);
            httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8");

            // Set Credentials
            if (NetworkManagementClient.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await NetworkManagementClient.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            cancellationToken.ThrowIfCancellationRequested();

            var client = this.NetworkManagementClient as NetworkManagementClient;
            HttpClient httpClient = client.HttpClient;
            HttpResponseMessage httpResponse = await httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

            HttpStatusCode statusCode = httpResponse.StatusCode;
            cancellationToken.ThrowIfCancellationRequested();
            if ((int)statusCode != 202)
            {
                string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                throw new Exception(string.Format("Get-AzureRmVpnClientPackage Operation returned an invalid status code '{0}' with Exception:{1}",
                    statusCode, string.IsNullOrEmpty(responseContent) ? "NotAvailable" : responseContent));
            }

            // Create Result
            var result = new AzureOperationResponse<string>();
            result.Request = httpRequest;
            result.Response = httpResponse;
            string locationResultsUrl = string.Empty;

            // Retrieve the location from LocationUri
            if (httpResponse.Headers.Contains("Location"))
            {
                locationResultsUrl = httpResponse.Headers.GetValues("Location").FirstOrDefault();
            }
            else
            {
                throw new Exception(string.Format("Get-AzureRmVpnClientPackage Operation Failed as no valid Location header received in response!"));
            }
//.........这里部分代码省略.........
开发者ID:Azure,项目名称:azure-powershell,代码行数:101,代码来源:NetworkClient.cs

示例12: CalculateRelativePathToSlimjimPackages

 public static string CalculateRelativePathToSlimjimPackages(string packagesPath, string csProjPath)
 {
     var relativeUri = new Uri(csProjPath).MakeRelativeUri(new Uri(packagesPath)).OriginalString;
     return relativeUri.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
 }
开发者ID:themotleyfool,项目名称:SlimJim,代码行数:5,代码来源:HintPathConverter.cs

示例13: ButtonClicked

        private void ButtonClicked(object sender, EventArgs e)
        {
            Project currentProject = GetSelectedProjects().ElementAt(0);
            var projects = _dte.Solution.GetAllNonWebProjects();
            var names = from p in projects
                        where p.UniqueName != currentProject.UniqueName
                        select p.Name;

            ProjectSelector2 selector = new ProjectSelector2(names);
            bool? isSelected = selector.ShowDialog();

            if (isSelected.HasValue && isSelected.Value)
            {
                WebJobCreator creator = new WebJobCreator();
                var selectedProject = projects.First(p => p.Name == selector.SelectedProjectName);
                creator.AddReference(currentProject, selectedProject);
                var relativePath = new Uri(currentProject.FullName).MakeRelativeUri(new Uri(selectedProject.FullName)).ToString();
                relativePath = relativePath.Replace("/", "\\");
                creator.CreateFolders(currentProject, selector.Schedule, selector.SelectedProjectName, relativePath);

                // ensure that the NuGet package is installed in the project as well
                InstallWebJobsNuGetPackage(currentProject);
            }
        }
开发者ID:modulexcite,项目名称:webjobsvs,代码行数:24,代码来源:WebJobsVsPackage.cs

示例14: IsExternalLink

 private bool IsExternalLink(string url)
 {
     try
     {
         var link = new Uri(url).Host;
         link = link.Replace("www.", string.Empty);
         return !link.StartsWith(_hostOfOriginalUrl);
     }
     catch (FormatException)
     {
         return false;
     }
 }
开发者ID:ncpenn,项目名称:FindBrokenLinksCommandLine,代码行数:13,代码来源:Spider.cs


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