本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.ListContainers方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.ListContainers方法的具体用法?C# CloudFilesProvider.ListContainers怎么用?C# CloudFilesProvider.ListContainers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.ListContainers方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Return_Container_List
public void Should_Return_Container_List()
{
var provider = new CloudFilesProvider();
var containerList = provider.ListContainers(identity: _testIdentity);
Assert.IsNotNull(containerList);
Assert.IsTrue(containerList.Any());
}
示例2: Should_Return_Container_List_With_Internal_Url
public void Should_Return_Container_List_With_Internal_Url()
{
var provider = new CloudFilesProvider();
var containerList = provider.ListContainers(useInternalUrl:true, identity: _testIdentity);
Assert.IsNotNull(containerList);
Assert.IsTrue(containerList.Any());
}
示例3: CFProviderListContainers
protected void CFProviderListContainers(string dcregion, bool dcsnet = true)
{
var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };
CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);
var CfContainers = CloudFilesProvider.ListContainers(null, null, null, dcregion, dcsnet);
CFContainerDDL.DataSource = CfContainers;
CFContainerDDL.DataTextField = "Name";
CFContainerDDL.DataBind();
}
示例4: ListContainers
private IEnumerable<Container> ListContainers(CloudIdentity cloudIdentity, int? limit = null, string region = null, bool useInternalUrl = false) {
var provider = new CloudFilesProvider(cloudIdentity);
Container lastContainer = null;
do {
string marker = lastContainer != null ? lastContainer.Name : null;
IEnumerable<Container> containerObjects = provider.ListContainers(limit, marker, null, region, useInternalUrl, cloudIdentity);
lastContainer = null;
foreach (Container containerObject in containerObjects) {
lastContainer = containerObject;
yield return containerObject;
}
} while (lastContainer != null);
}
示例5: Should_Return_Container_List_With_Limit
public void Should_Return_Container_List_With_Limit()
{
var provider = new CloudFilesProvider();
var containerList = provider.ListContainers(1, identity: _testIdentity);
Assert.IsNotNull(containerList);
Assert.AreEqual(1, containerList.Count());
}
示例6: Should_Return_Container_List_With_End_Marker_Lower_Case
public void Should_Return_Container_List_With_End_Marker_Lower_Case()
{
var provider = new CloudFilesProvider();
var containerList = provider.ListContainers(null, null, "l", identity: _testIdentity);
Assert.IsNotNull(containerList);
Assert.IsTrue(containerList.Any());
}
示例7: Should_Purge_Objects_Before_Deleting_The_Conatiner
public void Should_Purge_Objects_Before_Deleting_The_Conatiner()
{
var provider = new CloudFilesProvider(_testIdentity);
provider.DeleteContainer(containerName2);
var containers = provider.ListContainers();
Assert.IsFalse(containers.Any(c => c.Name.Equals(containerName2)));
}
示例8: Should_Create_New_Test_Container_2
public void Should_Create_New_Test_Container_2()
{
var provider = new CloudFilesProvider(_testIdentity);
provider.CreateContainer(containerName2);
var containers = provider.ListContainers();
Assert.IsTrue(containers.Any(c => c.Name.Equals(containerName2)));
}
示例9: Main
public static void Main(string[] args)
{
Boolean containerExists = false;
if (args.Length < 4 || args.Length > 5)
{
Console.WriteLine("Usage: {0} username api_key target_container path_to_file [region (US|UK)]", Environment.CommandLine);
Environment.Exit(1);
}
RackspaceCloudIdentity auth = new RackspaceCloudIdentity();
IEnumerable<Container> containerList = null;
auth.Username = args[0];
auth.APIKey = args[1];
targetContainer = args[2];
filePath = args[3];
if (args.Length == 5)
{
if (args[4] != "UK" && args[4] != "US")
{
Console.WriteLine("region must be either US or UK", Environment.CommandLine);
Environment.Exit(1);
}
switch (args[4])
{
case "UK": {auth.CloudInstance = CloudInstance.UK;};break;
case "US": { auth.CloudInstance = CloudInstance.Default;}; break;
}
}
try
{
IIdentityProvider identityProvider = new CloudIdentityProvider();
var userAccess = identityProvider.Authenticate(auth);
}
catch (ResponseException ex2)
{
Console.WriteLine("Authentication failed with the following message: {0}",ex2.Message);
Environment.Exit(1);
}
try
{
var cloudFilesProvider = new CloudFilesProvider(auth);
containerList = cloudFilesProvider.ListContainers();
foreach (Container container in containerList)
{
if (container.Name == targetContainer)
{
containerExists = true;
break;
}
}
if (!containerExists)
{
Console.WriteLine("Container \"{0}\" does not exist on the provided CloudFiles account.", targetContainer);
Environment.Exit(1);
}
if (!File.Exists(filePath))
{
Console.WriteLine("The file specified ({0}) does not exist", filePath);
Environment.Exit(1);
}
cloudFilesProvider.CreateObjectFromFile(targetContainer, @filePath, Path.GetFileName(filePath));
}
catch (Exception ex2)
{
Console.WriteLine(ex2.Message);
Environment.Exit(1);
}
Console.WriteLine("*SUCCESS* File: \"{0}\" uploaded to \"{1}\"", filePath, targetContainer);
}