From 21591a4a7a5875e140ec2d0c19db7a110cc4a491 Mon Sep 17 00:00:00 2001 From: Adrien Siffermann Date: Wed, 29 Jun 2016 03:19:28 +0200 Subject: [PATCH] CR and patch List in FileSystem provider --- GeekLearning.Storage.sln | 8 + LICENSE.md | 2 +- README.md | 2 +- .../Project_Readme.html | 187 ------------------ .../AzureStorageManagerOptions.cs | 10 +- .../AzureStorageProvider.cs | 70 +------ .../GeekLearningAzureStorageExtensions.cs | 15 +- src/GeekLearning.Storage.Azure/project.json | 22 ++- .../FileSystemStorageProvider.cs | 13 +- .../FileSystemStore.cs | 5 +- ...GeekLearningFileSystemStorageExtensions.cs | 16 +- .../project.json | 24 ++- .../GeekLearningStorageExtensions.cs | 13 +- src/GeekLearning.Storage/IStorageFactory.cs | 7 +- src/GeekLearning.Storage/IStorageProvider.cs | 9 +- src/GeekLearning.Storage/IStore.cs | 12 +- src/GeekLearning.Storage/StorageFactory.cs | 12 +- src/GeekLearning.Storage/StorageOptions.cs | 10 +- src/GeekLearning.Storage/StoreBase.cs | 7 +- src/GeekLearning.Storage/project.json | 20 +- 20 files changed, 95 insertions(+), 369 deletions(-) delete mode 100644 samples/GeekLearning.Storage.BasicSample/Project_Readme.html diff --git a/GeekLearning.Storage.sln b/GeekLearning.Storage.sln index 40afd88..0e7b697 100644 --- a/GeekLearning.Storage.sln +++ b/GeekLearning.Storage.sln @@ -17,6 +17,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2DAF5EF9 EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "GeekLearning.Integration.Test", "tests\GeekLearning.Integration.Test\GeekLearning.Integration.Test.xproj", "{590B21B0-2AFA-4329-82AD-EF180C50EB5C}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6BEB33C6-FA17-4F58-ACC3-83C1EB28B604}" + ProjectSection(SolutionItems) = preProject + .gitattributes = .gitattributes + .gitignore = .gitignore + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/LICENSE.md b/LICENSE.md index ca73459..82640a0 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) ===================== -Copyright © `2016` `Geek Learning, Cyprien Autexier` +Copyright © `2016` `Geek Learning, Cyprien Autexier, Adrien Siffermann` Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index 75f54f7..c121e78 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Storage.svg?style=flat-square&label=nuget:%20primitives)](https://www.nuget.org/packages/GeekLearning.Storage/) [![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Storage.FileSystem.svg?style=flat-square&label=nuget:%20filesystem)](https://www.nuget.org/packages/GeekLearning.Storage.FileSystem/) [![NuGet Version](http://img.shields.io/nuget/v/GeekLearning.Storage.Azure.svg?style=flat-square&label=nuget:%20azure%20 storage)](https://www.nuget.org/packages/GeekLearning.Storage.Azure/) -[![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/5/badge)](#) +[![Build Status](https://geeklearning.visualstudio.com/_apis/public/build/definitions/f841b266-7595-4d01-9ee1-4864cf65aa73/27/badge)](#) # gl-dotnet-storage diff --git a/samples/GeekLearning.Storage.BasicSample/Project_Readme.html b/samples/GeekLearning.Storage.BasicSample/Project_Readme.html deleted file mode 100644 index bddf864..0000000 --- a/samples/GeekLearning.Storage.BasicSample/Project_Readme.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - Welcome to ASP.NET Core - - - - - - -
-
-

This application consists of:

-
    -
  • Sample pages using ASP.NET Core MVC
  • -
  • Gulp and Bower for managing client-side libraries
  • -
  • Theming using Bootstrap
  • -
-
- - - - - -
- - - diff --git a/src/GeekLearning.Storage.Azure/AzureStorageManagerOptions.cs b/src/GeekLearning.Storage.Azure/AzureStorageManagerOptions.cs index cd4d6bb..b79dae4 100644 --- a/src/GeekLearning.Storage.Azure/AzureStorageManagerOptions.cs +++ b/src/GeekLearning.Storage.Azure/AzureStorageManagerOptions.cs @@ -1,13 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage.Azure +namespace GeekLearning.Storage.Azure { + using System.Collections.Generic; + public class AzureStorageManagerOptions { - public Dictionary SubStores { get; set; } public class SubStore diff --git a/src/GeekLearning.Storage.Azure/AzureStorageProvider.cs b/src/GeekLearning.Storage.Azure/AzureStorageProvider.cs index 6746607..e7fa3c9 100644 --- a/src/GeekLearning.Storage.Azure/AzureStorageProvider.cs +++ b/src/GeekLearning.Storage.Azure/AzureStorageProvider.cs @@ -1,17 +1,9 @@ -using GeekLearning.Storage; -using Microsoft.WindowsAzure.Storage; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage.Azure +namespace GeekLearning.Storage.Azure { + using Storage; + public class AzureStorageProvider : IStorageProvider { - private AzureStorageManagerOptions options; - public string Name { get @@ -24,61 +16,5 @@ public IStore BuildStore(StorageOptions.StorageStore storeOptions) { return new AzureStore(storeOptions.Parameters["ConnectionString"], storeOptions.Parameters["Container"]); } - - //public AzureStorageProvider(IOptions options) - //{ - // this.options = options.Value; - //} - - //public async Task StoreFile(byte[] data, string substore, string path, string mimeType) - //{ - // var subStoreConfig = this.options.SubStores[substore]; - // var account = CloudStorageAccount.Parse(subStoreConfig.ConnectionString); - // var blobClient = account.CreateCloudBlobClient(); - // var container = blobClient.GetContainerReference(subStoreConfig.Container); - // return await SaveToStorage(container, data, path, mimeType); - //} - - //private static async Task SaveToStorage(Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container, byte[] data, string path, string mimeType) - //{ - // var blockBlob = container.GetBlockBlobReference(path); - // await blockBlob.UploadFromByteArrayAsync(data, 0, data.Length); - // blockBlob.Properties.ContentType = mimeType; - // blockBlob.Properties.CacheControl = "max-age=300, must-revalidate"; - // await blockBlob.SetPropertiesAsync(); - // return blockBlob.Uri.ToString(); - //} - - //public async Task GetExpirableUri(string substore, string uri) - //{ - // Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy policy = new Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy() - // { - // Permissions = Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions.Read, - // SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(5), - // }; - // var subStoreConfig = this.options.SubStores[substore]; - // var account = CloudStorageAccount.Parse(subStoreConfig.ConnectionString); - // var blobClient = account.CreateCloudBlobClient(); - // var blobRef = await blobClient.GetBlobReferenceFromServerAsync(new Uri(uri)); - - // var sas = blobRef.GetSharedAccessSignature(policy); - - // return uri + sas; - //} - - //public Task ReadFile() - //{ - // throw new NotImplementedException(); - //} - - ////private static async Task SaveToStorage(Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container, MemoryStream ms, string name) - ////{ - //// var blockBlob = container.GetBlockBlobReference(name); - //// await blockBlob.UploadFromStreamAsync(ms); - //// blockBlob.Properties.ContentType = "image/jpeg"; - //// blockBlob.Properties.CacheControl = "max-age=300, must-revalidate"; - //// await blockBlob.SetPropertiesAsync(); - //// return blockBlob.Uri.ToString(); - ////} } } diff --git a/src/GeekLearning.Storage.Azure/GeekLearningAzureStorageExtensions.cs b/src/GeekLearning.Storage.Azure/GeekLearningAzureStorageExtensions.cs index 8f5f42d..150ec7c 100644 --- a/src/GeekLearning.Storage.Azure/GeekLearningAzureStorageExtensions.cs +++ b/src/GeekLearning.Storage.Azure/GeekLearningAzureStorageExtensions.cs @@ -1,14 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using GeekLearning.Storage; -using GeekLearning.Storage.Azure; - -namespace Microsoft.Extensions.DependencyInjection +namespace GeekLearning.Storage { + using Azure; + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection.Extensions; + public static class GeekLearningAzureStorageExtensions { diff --git a/src/GeekLearning.Storage.Azure/project.json b/src/GeekLearning.Storage.Azure/project.json index bdabf57..8236ff6 100644 --- a/src/GeekLearning.Storage.Azure/project.json +++ b/src/GeekLearning.Storage.Azure/project.json @@ -1,5 +1,5 @@ { - "version": "0.0.1-*", + "version": "1.0.0-*", "description": "GeekLearning.Storage.Azure Class Library", "authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ], "packOptions": { @@ -7,17 +7,23 @@ "projectUrl": "", "licenseUrl": "" }, - "frameworks": { - "net451": { }, - "netstandard1.5": { - "imports": [ "dotnet", "dnxcore50", "portable-net45+win8" ] - } - }, + "dependencies": { + "NETStandard.Library": "1.5.0-rc2-24027", "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-final", "Microsoft.Extensions.Options": "1.0.0-rc2-final", - "NETStandard.Library": "1.5.0-rc2-24027", "WindowsAzure.Storage": "7.0.1-preview", "GeekLearning.Storage": "*" + }, + + "frameworks": { + "net451": { }, + "netstandard1.5": { + "imports": [ + "dotnet5.6", + "dnxcore50", + "portable-net45+win8" + ] + } } } diff --git a/src/GeekLearning.Storage.FileSystem/FileSystemStorageProvider.cs b/src/GeekLearning.Storage.FileSystem/FileSystemStorageProvider.cs index 4f1f2a9..8194332 100644 --- a/src/GeekLearning.Storage.FileSystem/FileSystemStorageProvider.cs +++ b/src/GeekLearning.Storage.FileSystem/FileSystemStorageProvider.cs @@ -1,13 +1,8 @@ -using GeekLearning.Storage; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; - -namespace GeekLearning.Storage.FileSystem +namespace GeekLearning.Storage.FileSystem { + using Storage; + using Microsoft.AspNetCore.Hosting; + public class FileSystemStorageProvider : IStorageProvider { private IHostingEnvironment appEnv; diff --git a/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs b/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs index 6c386e0..f708d91 100644 --- a/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs +++ b/src/GeekLearning.Storage.FileSystem/FileSystemStore.cs @@ -45,7 +45,10 @@ public Task List(string path) return Task.FromResult(new string[0]); } - return Task.FromResult(Directory.GetFiles(directoryPath).Select(x => x.Replace(this.absolutePath, "").Trim('/', '\\')).ToArray()); + return Task.FromResult(Directory.GetFiles(directoryPath, path) + .Select(x => x.Replace(this.absolutePath, "") + .Trim('/', '\\')) + .ToArray()); } public Task Read(string path) diff --git a/src/GeekLearning.Storage.FileSystem/GeekLearningFileSystemStorageExtensions.cs b/src/GeekLearning.Storage.FileSystem/GeekLearningFileSystemStorageExtensions.cs index 2f48d7a..95dbeb7 100644 --- a/src/GeekLearning.Storage.FileSystem/GeekLearningFileSystemStorageExtensions.cs +++ b/src/GeekLearning.Storage.FileSystem/GeekLearningFileSystemStorageExtensions.cs @@ -1,17 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using GeekLearning.Storage; -using GeekLearning.Storage.FileSystem; - -namespace Microsoft.Extensions.DependencyInjection +namespace GeekLearning.Storage { + using FileSystem; + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection.Extensions; + public static class GeekLearningFileSystemStorageExtensions { - public static IServiceCollection AddFileSystemStorage(this IServiceCollection services) { services.TryAddEnumerable(ServiceDescriptor.Transient()); diff --git a/src/GeekLearning.Storage.FileSystem/project.json b/src/GeekLearning.Storage.FileSystem/project.json index 6601f1c..50830d8 100644 --- a/src/GeekLearning.Storage.FileSystem/project.json +++ b/src/GeekLearning.Storage.FileSystem/project.json @@ -1,5 +1,5 @@ { - "version": "0.0.1-*", + "version": "1.0.0-*", "description": "GeekLearning.Storage.FileSystem Class Library", "authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ], "packOptions": { @@ -7,17 +7,23 @@ "projectUrl": "", "licenseUrl": "" }, + + "dependencies": { + "NETStandard.Library": "1.5.0-rc2-24027", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-final", + "Microsoft.Extensions.Options": "1.0.0-rc2-final", + "Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0-rc2-final", + "GeekLearning.Storage": "*" + }, + "frameworks": { "net451": { }, "netstandard1.5": { - "imports": [ "dotnet", "dnxcore50", "portable-net45+win8" ] + "imports": [ + "dotnet5.6", + "dnxcore50", + "portable-net45+win8" + ] } - }, - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-final", - "Microsoft.Extensions.Options": "1.0.0-rc2-final", - "NETStandard.Library": "1.5.0-rc2-24027", - "GeekLearning.Storage": "*", - "Microsoft.AspNetCore.Hosting.Abstractions": "1.0.0-rc2-final" } } diff --git a/src/GeekLearning.Storage/GeekLearningStorageExtensions.cs b/src/GeekLearning.Storage/GeekLearningStorageExtensions.cs index 1960794..572f2ad 100644 --- a/src/GeekLearning.Storage/GeekLearningStorageExtensions.cs +++ b/src/GeekLearning.Storage/GeekLearningStorageExtensions.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using GeekLearning.Storage; - -namespace Microsoft.Extensions.DependencyInjection +namespace GeekLearning.Storage { + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection.Extensions; + public static class GeekLearningStorageExtensions { public static IServiceCollection AddStorage(this IServiceCollection services) diff --git a/src/GeekLearning.Storage/IStorageFactory.cs b/src/GeekLearning.Storage/IStorageFactory.cs index 7128003..3b7ad85 100644 --- a/src/GeekLearning.Storage/IStorageFactory.cs +++ b/src/GeekLearning.Storage/IStorageFactory.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage +namespace GeekLearning.Storage { public interface IStorageFactory { diff --git a/src/GeekLearning.Storage/IStorageProvider.cs b/src/GeekLearning.Storage/IStorageProvider.cs index 8444f5c..630740a 100644 --- a/src/GeekLearning.Storage/IStorageProvider.cs +++ b/src/GeekLearning.Storage/IStorageProvider.cs @@ -1,16 +1,9 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage +namespace GeekLearning.Storage { public interface IStorageProvider { string Name { get; } - IStore BuildStore(StorageOptions.StorageStore storeOptions); } } diff --git a/src/GeekLearning.Storage/IStore.cs b/src/GeekLearning.Storage/IStore.cs index 9910030..f9debe9 100644 --- a/src/GeekLearning.Storage/IStore.cs +++ b/src/GeekLearning.Storage/IStore.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage +namespace GeekLearning.Storage { + using System.IO; + using System.Threading.Tasks; + public interface IStore { - Task List(string path); Task Delete(string path); diff --git a/src/GeekLearning.Storage/StorageFactory.cs b/src/GeekLearning.Storage/StorageFactory.cs index 8d6ef0b..1996eda 100644 --- a/src/GeekLearning.Storage/StorageFactory.cs +++ b/src/GeekLearning.Storage/StorageFactory.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.Extensions.Options; - -namespace GeekLearning.Storage +namespace GeekLearning.Storage { + using Microsoft.Extensions.Options; + using System.Collections.Generic; + using System.Linq; + internal class StorageFactory : IStorageFactory { private IOptions options; diff --git a/src/GeekLearning.Storage/StorageOptions.cs b/src/GeekLearning.Storage/StorageOptions.cs index bb7684d..44943aa 100644 --- a/src/GeekLearning.Storage/StorageOptions.cs +++ b/src/GeekLearning.Storage/StorageOptions.cs @@ -1,15 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage +namespace GeekLearning.Storage { + using System.Collections.Generic; + public class StorageOptions { public StorageOptions() { - } public Dictionary Stores { get; set; } diff --git a/src/GeekLearning.Storage/StoreBase.cs b/src/GeekLearning.Storage/StoreBase.cs index 83c7942..86ea12f 100644 --- a/src/GeekLearning.Storage/StoreBase.cs +++ b/src/GeekLearning.Storage/StoreBase.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GeekLearning.Storage +namespace GeekLearning.Storage { public abstract class StoreBase { diff --git a/src/GeekLearning.Storage/project.json b/src/GeekLearning.Storage/project.json index ce44156..ac6fae9 100644 --- a/src/GeekLearning.Storage/project.json +++ b/src/GeekLearning.Storage/project.json @@ -1,5 +1,5 @@ { - "version": "0.0.1-*", + "version": "1.0.0-*", "description": "GeekLearning.Storage Class Library", "authors": [ "Geek Learning", "Cyprien Autexier", "Adrien Siffermann" ], "packOptions": { @@ -7,15 +7,21 @@ "projectUrl": "", "licenseUrl": "" }, + + "dependencies": { + "NETStandard.Library": "1.5.0-rc2-24027", + "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-final", + "Microsoft.Extensions.Options": "1.0.0-rc2-final" + }, + "frameworks": { "net451": { }, "netstandard1.5": { - "imports": [ "dotnet", "dnxcore50", "portable-net45+win8" ] + "imports": [ + "dotnet5.6", + "dnxcore50", + "portable-net45+win8" + ] } - }, - "dependencies": { - "Microsoft.Extensions.DependencyInjection.Abstractions": "1.0.0-rc2-final", - "Microsoft.Extensions.Options": "1.0.0-rc2-final", - "NETStandard.Library": "1.5.0-rc2-24027" } }