本文整理汇总了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);
}
示例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>()
});
}
示例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;
}
示例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
}
示例5: PathFactory
public PathFactory(Uri basePostUri, Uri baseImageUri)
{
_basePostUri = basePostUri.EnsureTrailingSlash();
_baseImageUri = baseImageUri.EnsureTrailingSlash();
}
示例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>();
}
}
示例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();
}