Update content
This commit is contained in:
Родитель
4d29c19c87
Коммит
3bbf73a1a2
|
@ -1,8 +1,11 @@
|
|||
namespace King.Azure.Data
|
||||
{
|
||||
using Microsoft.WindowsAzure.Storage.Blob;
|
||||
using Microsoft.WindowsAzure.Storage.Queue;
|
||||
using Microsoft.WindowsAzure.Storage.Table;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using System.Threading.Tasks;
|
||||
/// <summary>
|
||||
/// Azure Storage Resources
|
||||
/// </summary>
|
||||
|
@ -24,69 +27,115 @@
|
|||
/// List Table Names
|
||||
/// </summary>
|
||||
/// <returns>Table Names</returns>
|
||||
public virtual IEnumerable<string> TableNames()
|
||||
public virtual async Task<IEnumerable<string>> TableNames()
|
||||
{
|
||||
TableContinuationToken token = null;
|
||||
var names = new List<string>();
|
||||
|
||||
var client = base.Account.CreateCloudTableClient();
|
||||
return client.ListTables().Select(t => t.Name);
|
||||
|
||||
do
|
||||
{
|
||||
var segments = await client.ListTablesSegmentedAsync(token);
|
||||
names.AddRange(segments.Results.Select(s => s.Name));
|
||||
token = segments.ContinuationToken;
|
||||
}
|
||||
while (null != token);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List Tables
|
||||
/// </summary>
|
||||
/// <returns>Tables</returns>
|
||||
public virtual IEnumerable<ITableStorage> Tables()
|
||||
public virtual async Task<IEnumerable<ITableStorage>> Tables()
|
||||
{
|
||||
var names = this.TableNames();
|
||||
var tables = new List<ITableStorage>();
|
||||
|
||||
var names = await this.TableNames();
|
||||
foreach (var name in names)
|
||||
{
|
||||
yield return new TableStorage(name, base.Account);
|
||||
tables.Add(new TableStorage(name, base.Account));
|
||||
}
|
||||
|
||||
return tables;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List Container Names
|
||||
/// </summary>
|
||||
/// <returns>Container Names</returns>
|
||||
public virtual IEnumerable<string> ContainerNames()
|
||||
public virtual async Task<IEnumerable<string>> ContainerNames()
|
||||
{
|
||||
BlobContinuationToken token = null;
|
||||
var names = new List<string>();
|
||||
|
||||
var client = base.Account.CreateCloudBlobClient();
|
||||
return client.ListContainers().Select(c => c.Name);
|
||||
|
||||
do
|
||||
{
|
||||
var segments = await client.ListContainersSegmentedAsync(token);
|
||||
names.AddRange(segments.Results.Select(s => s.Name));
|
||||
token = segments.ContinuationToken;
|
||||
}
|
||||
while (null != token);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List Containers
|
||||
/// </summary>
|
||||
/// <returns>Containers</returns>
|
||||
public virtual IEnumerable<IContainer> Containers()
|
||||
public virtual async Task<IEnumerable<IContainer>> Containers()
|
||||
{
|
||||
var names = this.ContainerNames();
|
||||
var containers = new List<IContainer>();
|
||||
var names = await this.ContainerNames();
|
||||
foreach (var name in names)
|
||||
{
|
||||
yield return new Container(name, base.Account);
|
||||
containers.Add(new Container(name, base.Account));
|
||||
}
|
||||
|
||||
return containers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List Queue Names
|
||||
/// </summary>
|
||||
/// <returns>Queue Names</returns>
|
||||
public virtual IEnumerable<string> QueueNames()
|
||||
public virtual async Task<IEnumerable<string>> QueueNames()
|
||||
{
|
||||
QueueContinuationToken token = null;
|
||||
var names = new List<string>();
|
||||
|
||||
var client = base.Account.CreateCloudQueueClient();
|
||||
return client.ListQueues().Select(q => q.Name);
|
||||
|
||||
do
|
||||
{
|
||||
var segments = await client.ListQueuesSegmentedAsync(token);
|
||||
names.AddRange(segments.Results.Select(s => s.Name));
|
||||
token = segments.ContinuationToken;
|
||||
}
|
||||
while (null != token);
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List Queues
|
||||
/// </summary>
|
||||
/// <returns>Queues</returns>
|
||||
public virtual IEnumerable<IStorageQueue> Queues()
|
||||
public virtual async Task<IEnumerable<IStorageQueue>> Queues()
|
||||
{
|
||||
var names = this.QueueNames();
|
||||
var queues = new List<IStorageQueue>();
|
||||
var names = await this.QueueNames();
|
||||
foreach (var name in names)
|
||||
{
|
||||
yield return new StorageQueue(name, base.Account);
|
||||
queues.Add(new StorageQueue(name, base.Account));
|
||||
}
|
||||
|
||||
return queues;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -445,9 +445,22 @@
|
|||
/// <param name="prefix">Prefix</param>
|
||||
/// <param name="useFlatBlobListing">Use Flat Blob Listing</param>
|
||||
/// <returns>Blobs</returns>
|
||||
public IEnumerable<IListBlobItem> List(string prefix = null, bool useFlatBlobListing = false)
|
||||
public async Task<IEnumerable<IListBlobItem>> List(string prefix = null, bool useFlatBlobListing = false, BlobListingDetails details = BlobListingDetails.All, int? maxResults = int.MaxValue)
|
||||
{
|
||||
return this.reference.ListBlobs(prefix, useFlatBlobListing);
|
||||
BlobContinuationToken token = null;
|
||||
var blobs = new List<IListBlobItem>();
|
||||
var options = new BlobRequestOptions();
|
||||
var operationContext = new OperationContext();
|
||||
|
||||
do
|
||||
{
|
||||
var segments = await this.reference.ListBlobsSegmentedAsync(prefix, useFlatBlobListing, details, maxResults, token, options, operationContext);
|
||||
blobs.AddRange(segments.Results);
|
||||
token = segments.ContinuationToken;
|
||||
}
|
||||
while (null != token);
|
||||
|
||||
return blobs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -467,7 +480,8 @@
|
|||
LocationMode = LocationMode.PrimaryOnly,
|
||||
};
|
||||
|
||||
var blob = this.List(blobName).FirstOrDefault();
|
||||
var blobs = await this.List(blobName);
|
||||
var blob = blobs.FirstOrDefault();
|
||||
var block = blob as CloudBlockBlob;
|
||||
if (null != block)
|
||||
{
|
||||
|
|
|
@ -353,7 +353,7 @@
|
|||
/// <param name="prefix">Prefix</param>
|
||||
/// <param name="useFlatBlobListing">Use Flat Blob Listing</param>
|
||||
/// <returns>Blobs</returns>
|
||||
IEnumerable<IListBlobItem> List(string prefix = null, bool useFlatBlobListing = false);
|
||||
Task<IEnumerable<IListBlobItem>> List(string prefix = null, bool useFlatBlobListing = false, BlobListingDetails details = BlobListingDetails.All, int? maxResults = int.MaxValue);
|
||||
|
||||
/// <summary>
|
||||
/// Create Snapshot
|
||||
|
@ -602,37 +602,37 @@
|
|||
/// List Table Names
|
||||
/// </summary>
|
||||
/// <returns>Table Names</returns>
|
||||
IEnumerable<string> TableNames();
|
||||
Task<IEnumerable<string>> TableNames();
|
||||
|
||||
/// <summary>
|
||||
/// List Tables
|
||||
/// </summary>
|
||||
/// <returns>Tables</returns>
|
||||
IEnumerable<ITableStorage> Tables();
|
||||
Task<IEnumerable<ITableStorage>> Tables();
|
||||
|
||||
/// <summary>
|
||||
/// List Container Names
|
||||
/// </summary>
|
||||
/// <returns>Container Names</returns>
|
||||
IEnumerable<string> ContainerNames();
|
||||
Task<IEnumerable<string>> ContainerNames();
|
||||
|
||||
/// <summary>
|
||||
/// List Containers
|
||||
/// </summary>
|
||||
/// <returns>Containers</returns>
|
||||
IEnumerable<IContainer> Containers();
|
||||
Task<IEnumerable<IContainer>> Containers();
|
||||
|
||||
/// <summary>
|
||||
/// List Queue Names
|
||||
/// </summary>
|
||||
/// <returns>Queue Names</returns>
|
||||
IEnumerable<string> QueueNames();
|
||||
Task<IEnumerable<string>> QueueNames();
|
||||
|
||||
/// <summary>
|
||||
/// List Queues
|
||||
/// </summary>
|
||||
/// <returns>Queues</returns>
|
||||
IEnumerable<IStorageQueue> Queues();
|
||||
Task<IEnumerable<IStorageQueue>> Queues();
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -11,5 +11,5 @@ using System.Runtime.InteropServices;
|
|||
[assembly: AssemblyCulture("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("4e7ae8fe-0ee3-44a4-bae7-2ea46062c10e")]
|
||||
[assembly: AssemblyVersion("1.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
||||
[assembly: AssemblyVersion("2.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.0.0")]
|
|
@ -3,7 +3,7 @@
|
|||
using Microsoft.WindowsAzure.Storage;
|
||||
using Microsoft.WindowsAzure.Storage.RetryPolicies;
|
||||
using Microsoft.WindowsAzure.Storage.Table;
|
||||
using Microsoft.WindowsAzure.Storage.Table.Queryable;
|
||||
//using Microsoft.WindowsAzure.Storage.Table.Queryable;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -397,12 +397,16 @@
|
|||
throw new InvalidOperationException("maxResults: must be above 0.");
|
||||
}
|
||||
|
||||
var query = this.reference.CreateQuery<T>()
|
||||
.Where(predicate)
|
||||
.Take(maxResults)
|
||||
.AsTableQuery<T>();
|
||||
//var query = this.reference.CreateQuery<T>()
|
||||
// .Where(predicate)
|
||||
// .Take(maxResults)
|
||||
// .AsTableQuery<T>();
|
||||
|
||||
return await this.Query<T>(query);
|
||||
//return await this.Query<T>(query);
|
||||
|
||||
await Task.FromResult<bool>(false);
|
||||
|
||||
throw new InvalidOperationException("Not Implemented");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "King.Azure Class Library",
|
||||
"authors": [ "jefkin" ],
|
||||
"tags": [ "" ],
|
||||
"projectUrl": "",
|
||||
"licenseUrl": "",
|
||||
|
||||
"dependencies": {
|
||||
"WindowsAzure.Storage": "7.0.1-preview"
|
||||
},
|
||||
"version": "2.0.0-*",
|
||||
"title": "King.Azure",
|
||||
"description": "King.Azure.Data Class Library",
|
||||
"authors": [ "Jef King" ],
|
||||
"owners": [ "Jef King" ],
|
||||
"tags": [ "King.Azure Azure Storage Mock Mockable Simple Data Table Storage File Share File-Share Queue Queuing Blob Query dependency injection dependency-injection Cloud Table-Storage Windows-Azure Windows dotNet CSharp Mocking Data-Table Blob Json WindowsAzure.Storage .NetCore DNX" ],
|
||||
"projectUrl": "https://github.com/jefking/King.Azure",
|
||||
"licenseUrl": "https://github.com/jefking/King.Azure/blob/master/LICENSE",
|
||||
"iconUrl": "https://raw.githubusercontent.com/jefking/King.Azure/master/icon.png",
|
||||
"copyright": "Jef King",
|
||||
"language": "en-us",
|
||||
|
||||
"frameworks": {
|
||||
"net451": { },
|
||||
|
@ -21,5 +22,8 @@
|
|||
"System.Threading": "4.0.11-beta-23516"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"WindowsAzure.Storage": "7.0.1-preview"
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче