本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.DisableCDNOnContainer方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.DisableCDNOnContainer方法的具体用法?C# CloudFilesProvider.DisableCDNOnContainer怎么用?C# CloudFilesProvider.DisableCDNOnContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.DisableCDNOnContainer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Make_Container_CDN_Disabled
public void Should_Make_Container_CDN_Disabled()
{
var provider = new CloudFilesProvider();
var cdnEnabledResponse = provider.DisableCDNOnContainer(containerName, identity: _testIdentity);
var cdnContainerHeaderResponse = provider.GetContainerCDNHeader(containerName, identity: _testIdentity);
Assert.IsFalse(cdnContainerHeaderResponse.CDNEnabled);
}
示例2: TestCDNOnContainer
//.........这里部分代码省略.........
Assert.IsTrue(
containerHeader.CDNUri != null
|| containerHeader.CDNIosUri != null
|| containerHeader.CDNSslUri != null
|| containerHeader.CDNStreamingUri != null);
// Call the other overloads of EnableCDNOnContainer
cdnHeaders = provider.EnableCDNOnContainer(containerName, containerHeader.Ttl);
ContainerCDN updatedHeader = provider.GetContainerCDNHeader(containerName);
Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
Assert.IsNotNull(updatedHeader);
Assert.IsTrue(updatedHeader.CDNEnabled);
Assert.IsFalse(updatedHeader.LogRetention);
Assert.IsTrue(
updatedHeader.CDNUri != null
|| updatedHeader.CDNIosUri != null
|| updatedHeader.CDNSslUri != null
|| updatedHeader.CDNStreamingUri != null);
Assert.AreEqual(containerHeader.Ttl, updatedHeader.Ttl);
cdnHeaders = provider.EnableCDNOnContainer(containerName, containerHeader.Ttl, true);
updatedHeader = provider.GetContainerCDNHeader(containerName);
Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
Assert.IsNotNull(updatedHeader);
Assert.IsTrue(updatedHeader.CDNEnabled);
Assert.IsTrue(updatedHeader.LogRetention);
Assert.IsTrue(
updatedHeader.CDNUri != null
|| updatedHeader.CDNIosUri != null
|| updatedHeader.CDNSslUri != null
|| updatedHeader.CDNStreamingUri != null);
Assert.AreEqual(containerHeader.Ttl, updatedHeader.Ttl);
// update the container CDN properties
Dictionary<string, string> headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{ CloudFilesProvider.CdnTTL, (updatedHeader.Ttl + 1).ToString() },
{ CloudFilesProvider.CdnLogRetention, false.ToString() },
//{ CloudFilesProvider.CdnEnabled, true.ToString() },
};
provider.UpdateContainerCdnHeaders(containerName, headers);
updatedHeader = provider.GetContainerCDNHeader(containerName);
Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
Assert.IsNotNull(updatedHeader);
Assert.IsTrue(updatedHeader.CDNEnabled);
Assert.IsFalse(updatedHeader.LogRetention);
Assert.IsTrue(
updatedHeader.CDNUri != null
|| updatedHeader.CDNIosUri != null
|| updatedHeader.CDNSslUri != null
|| updatedHeader.CDNStreamingUri != null);
Assert.AreEqual(containerHeader.Ttl + 1, updatedHeader.Ttl);
// attempt to access the container over the CDN
if (containerHeader.CDNUri != null || containerHeader.CDNSslUri != null)
{
string baseUri = containerHeader.CDNUri ?? containerHeader.CDNSslUri;
Uri uri = new Uri(containerHeader.CDNUri + '/' + objectName);
WebRequest request = HttpWebRequest.Create(uri);
using (WebResponse response = request.GetResponse())
{
Stream cdnStream = response.GetResponseStream();
StreamReader reader = new StreamReader(cdnStream, Encoding.UTF8);
string text = reader.ReadToEnd();
Assert.AreEqual(fileContents, text);
}
}
else
{
Assert.Inconclusive("This integration test relies on cdn_uri or cdn_ssl_uri.");
}
IEnumerable<ContainerCDN> containers = ListAllCDNContainers(provider);
Console.WriteLine("Containers");
foreach (ContainerCDN container in containers)
{
Console.WriteLine(" {1}{0}", container.Name, container.CDNEnabled ? "*" : "");
}
cdnHeaders = provider.DisableCDNOnContainer(containerName);
Assert.IsNotNull(cdnHeaders);
Console.WriteLine("CDN Headers from DisableCDNOnContainer");
foreach (var pair in cdnHeaders)
Console.WriteLine(" {0}: {1}", pair.Key, pair.Value);
updatedHeader = provider.GetContainerCDNHeader(containerName);
Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
Assert.IsNotNull(updatedHeader);
Assert.IsFalse(updatedHeader.CDNEnabled);
Assert.IsFalse(updatedHeader.LogRetention);
Assert.IsTrue(
updatedHeader.CDNUri != null
|| updatedHeader.CDNIosUri != null
|| updatedHeader.CDNSslUri != null
|| updatedHeader.CDNStreamingUri != null);
Assert.AreEqual(containerHeader.Ttl + 1, updatedHeader.Ttl);
provider.DeleteContainer(containerName, deleteObjects: true);
}