本文整理汇总了C#中MindTouch.Dream.XUri.WithScheme方法的典型用法代码示例。如果您正苦于以下问题:C# XUri.WithScheme方法的具体用法?C# XUri.WithScheme怎么用?C# XUri.WithScheme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MindTouch.Dream.XUri
的用法示例。
在下文中一共展示了XUri.WithScheme方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqsClientConfig
//--- Constructors ---
/// <summary>
/// Constructor for creating an instance.
/// </summary>
/// <param name="privateKey">Private AWS key.</param>
/// <param name="publicKey">Public AWS key.</param>
/// <param name="accountId">AWS account ID.</param>
/// <param name="endpoint">Region name or custom SQS endpoint to use.</param>
/// <param name="secure">Boolean indicating if HTTPS should be used.</param>
/// <param name="proxyHost">The proxy host if any.</param>
/// <param name="proxyPort">The proxy port if any.</param>
public SqsClientConfig(string privateKey, string publicKey, string accountId, string endpoint, bool secure, string proxyHost = null, int? proxyPort = 0)
{
if(string.IsNullOrEmpty(accountId)) {
throw new ArgumentNullException("accountId");
}
if(string.IsNullOrEmpty(endpoint)) {
throw new ArgumentNullException("endpoint");
}
this.PrivateKey = privateKey;
this.PublicKey = publicKey;
this.AccountId = accountId;
this.ProxyHost = proxyHost;
this.ProxyPort = proxyPort;
// read end-point settings
XUri uri;
switch(endpoint) {
case "default":
case "us-east-1":
// US East (N. Virginia)
uri = new XUri("http://sqs.us-east-1.amazonaws.com");
break;
case "us-west-2":
// US West (Oregon)
uri = new XUri("http://sqs.us-west-2.amazonaws.com");
break;
case "us-west-1":
// US West (N. California)
uri = new XUri("http://sqs.us-west-1.amazonaws.com");
break;
case "eu-west-1":
// EU (Ireland)
uri = new XUri("http://sqs.eu-west-1.amazonaws.com");
break;
case "eu-central-1":
// EU (Frankfurt)
uri = new XUri("http://sqs.eu-central-1.amazonaws.com");
break;
case "ap-southeast-1":
// Asia Pacific (Singapore)
uri = new XUri("http://sqs.ap-southeast-1.amazonaws.com");
break;
case "ap-southeast-2":
// Asia Pacific (Sydney)
uri = new XUri("http://sqs.ap-southeast-2.amazonaws.com");
break;
case "ap-northeast-1":
// Asia Pacific (Tokyo)
uri = new XUri("http://sqs.ap-northeast-1.amazonaws.com");
break;
case "sa-east-1":
// South America (Sao Paulo)
uri = new XUri("http://sqs.sa-east-1.amazonaws.com");
break;
default:
uri = XUri.TryParse(endpoint);
break;
}
if(uri == null) {
throw new ArgumentException("invalid value for SQS end-point", "endpoint");
}
if(secure) {
uri = uri.WithScheme("https");
}
this.Endpoint = uri;
}
示例2: FetchFeed
private Result<DreamMessage> FetchFeed(XUri uri) {
// replace the invalid feed:// scheme with http://
if(uri.Scheme.EqualsInvariantIgnoreCase("feed")) {
uri = uri.WithScheme("http");
}
lock(_feeds) {
// check if we have a cached result
XDoc feed;
if(_feeds.TryGetValue(uri, out feed)) {
Result<DreamMessage> result = new Result<DreamMessage>();
result.Return(DreamMessage.Ok(feed));
return result;
}
}
Plug plug = Plug.New(uri, TimeSpan.FromSeconds(Config["timeout"].AsDouble ?? Plug.DEFAULT_TIMEOUT.TotalSeconds));
return plug.GetAsync();
}