當前位置: 首頁>>代碼示例>>C#>>正文


C# Uri.EnsureTrailingSlash方法代碼示例

本文整理匯總了C#中System.Uri.EnsureTrailingSlash方法的典型用法代碼示例。如果您正苦於以下問題:C# Uri.EnsureTrailingSlash方法的具體用法?C# Uri.EnsureTrailingSlash怎麽用?C# Uri.EnsureTrailingSlash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Uri的用法示例。


在下文中一共展示了Uri.EnsureTrailingSlash方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: EntryEndpoint

 /// <summary>
 /// Creates a new entry point using an OAuth token.
 /// </summary>
 /// <param name="uri">The base URI of the REST interface. Missing trailing slash will be appended automatically.</param>
 /// <param name="token">The OAuth token to present as a "Bearer" to the REST interface.</param>
 /// <param name="serializer">Controls the serialization of entities sent to and received from the server. Defaults to a JSON serializer if unset.</param>
 public EntryEndpoint(Uri uri, string token, MediaTypeFormatter serializer = null) : base(
     uri: uri.EnsureTrailingSlash(),
     httpClient: BuildHttpClient(uri),
     serializer: serializer ?? BuildSerializer())
 {
     HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
 }
開發者ID:1and1,項目名稱:TypedRest-DotNet,代碼行數:13,代碼來源:EntryEndpoint.cs

示例2: AddInstance

 public void AddInstance(string displayName, Uri serverUrl, bool requiresAuthentication)
 {
     this.Instances.Add(new JenkinsInstance
     {
         DisplayName = displayName,
         Url = serverUrl.EnsureTrailingSlash().ToString(),
         RequiresAuthentication = requiresAuthentication,
         FavoriteJobs = new System.Collections.Generic.List<string>()
     });
 }
開發者ID:Novakov,項目名稱:VisualStudio.Jenkins,代碼行數:10,代碼來源:Settings.cs

示例3: GetUriForImage

        public Uri GetUriForImage(string imageResourceName)
        {
            var uri = new Uri(_baseImageUri, new Uri(imageResourceName, UriKind.Relative));

            // we put a trailing slash here because the image resource names will contain at least one . about which the
            // mvc routing engine and IIS get confused.
            var uriWithTrailingSlash = uri.EnsureTrailingSlash();

            return uriWithTrailingSlash;
        }
開發者ID:uglybugger,項目名稱:BlogMonster,代碼行數:10,代碼來源:PathFactory.cs

示例4: ConnectionInformation

        internal ConnectionInformation(Uri serverUri, string userName, SecureString password)
        {
            if (serverUri == null)
            {
                throw new ArgumentNullException(nameof(serverUri));
            }

            this.ServerUri = serverUri.EnsureTrailingSlash();
            this.UserName = userName;
            this.Password = password?.CopyAsReadOnly();
            this.Authentication = AuthenticationType.Basic; // Only one supported at this point
        }
開發者ID:SonarSource-VisualStudio,項目名稱:sonarlint-visualstudio,代碼行數:12,代碼來源:ConnectionInformation.cs

示例5: PathFactory

 public PathFactory(Uri basePostUri, Uri baseImageUri)
 {
     _basePostUri = basePostUri.EnsureTrailingSlash();
     _baseImageUri = baseImageUri.EnsureTrailingSlash();
 }
開發者ID:uglybugger,項目名稱:BlogMonster,代碼行數:5,代碼來源:PathFactory.cs

示例6: GetRawLogFiles

        public async Task<IEnumerable<RawLogFileInfo>> GetRawLogFiles(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            var uriString = uri.ToString();
            try
            {
                _jobEventSource.BeginningDirectoryListing(uriString);
                Trace.TraceInformation("Listing directory '{0}'.", uri);

                var request = CreateRequest(uri);
                request.Method = WebRequestMethods.Ftp.ListDirectory;
                var webResponse = (FtpWebResponse)await request.GetResponseAsync();

                string directoryList;
                using (var streamReader = new StreamReader(webResponse.GetResponseStream(), Encoding.ASCII))
                {
                    directoryList = await streamReader.ReadToEndAsync();
                }

                _jobEventSource.FinishingDirectoryListing(uriString);

                var fileNames = directoryList.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                var rawLogFiles = fileNames.Select(fn => new RawLogFileInfo(new Uri(uri.EnsureTrailingSlash(), fn)));

                return rawLogFiles;
            }
            catch (Exception e)
            {
                _jobEventSource.FailedToGetRawLogFiles(uriString, e.ToString());
                Trace.TraceError("Failed to get raw log files: {0}", e);
                return Enumerable.Empty<RawLogFileInfo>();
            }
        }
開發者ID:joyhui,項目名稱:NuGet.Jobs,代碼行數:37,代碼來源:FtpRawLogClient.cs

示例7: Construct

        private void Construct(string id, Uri urlBase, bool useMime = false, IDictionary<string, string> nameValues = null) {
            ParameterCheck.ParameterRequired(id, "id");
            ParameterCheck.ParameterRequired(urlBase, "uriBase");

            this.id = id;
            this.urlBase = urlBase.EnsureTrailingSlash();
            this.useMime = useMime;
            this.nameValues = new ReadOnlyDictionary<string, string>(nameValues ?? new Dictionary<string, string>());

            this.folderInfo = new List<FileTransmitterFolderInfo>();

            this.localPath = urlBase.EnsureTrailingSlash().GetLocalPath();
        }
開發者ID:OnpointOnDemand,項目名稱:fluentjdf,代碼行數:13,代碼來源:FileTransmitterEncoder.cs


注:本文中的System.Uri.EnsureTrailingSlash方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。