Skip to content

Commit

Permalink
Update for .NET Core RTM
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Close committed Aug 6, 2016
1 parent 16ef273 commit b7f732c
Show file tree
Hide file tree
Showing 8 changed files with 4,293 additions and 4,505 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,7 @@ Temporary Items

*.user
*.suo
artifacts/
artifacts/
bin/
obj/
.vs/
2 changes: 1 addition & 1 deletion S3XmlRepository.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E83298AD-0B63-4124-8036-5B4E45800BBA}"
EndProject
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-rc1-update1"
"version": "1.0.0-preview2-003121"
}
}
10 changes: 5 additions & 5 deletions src/S3XmlRepository/S3DataProtectionBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using Amazon.S3;
using Microsoft.AspNet.DataProtection.Repositories;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.DataProtection.Repositories;
using Microsoft.Extensions.DependencyInjection;

namespace S3XmlRepository
Expand All @@ -26,13 +27,12 @@ private static void Use(IServiceCollection services, ServiceDescriptor descripto
}

/// <summary>
/// Configures the data protection system to persist keys to the specified directory.
/// This path may be on the local machine or may point to a UNC share.
/// Configures the data protection system to persist keys to Amazon S3.
/// </summary>
/// <param name="builder">The <see cref="IDataProtectionBuilder"/>.</param>
/// <param name="directory">The directory in which to store keys.</param>
/// <param name="configuration">The configuration item.</param>
/// <returns>A reference to the <see cref="IDataProtectionBuilder" /> after this operation has completed.</returns>
public static Microsoft.AspNet.DataProtection.DataProtectionConfiguration PersistKeysToS3(this Microsoft.AspNet.DataProtection.DataProtectionConfiguration builder, S3XmlRepositoryConfiguration configuration)
public static IDataProtectionBuilder PersistKeysToS3(this IDataProtectionBuilder builder, S3XmlRepositoryConfiguration configuration)
{
if (builder == null)
{
Expand Down
21 changes: 11 additions & 10 deletions src/S3XmlRepository/S3XmlRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
using System.Collections.Generic;
using System.IO;
using System.Xml.Linq;
using Microsoft.AspNet.DataProtection.Repositories;
using Amazon.S3;
using Amazon.S3.Model;
using System.Xml;
using System.Linq;
using Microsoft.AspNetCore.DataProtection.Repositories;

namespace S3XmlRepository
{
public class S3XmlRepositoryImpl : IXmlRepository
{
private IAmazonS3 _s3Client;
private S3XmlRepositoryConfiguration _configuration;
private readonly IAmazonS3 _s3Client;
private readonly S3XmlRepositoryConfiguration _configuration;

public S3XmlRepositoryImpl(IAmazonS3 s3Client, S3XmlRepositoryConfiguration configuration)
{
Expand All @@ -23,8 +22,7 @@ public S3XmlRepositoryImpl(IAmazonS3 s3Client, S3XmlRepositoryConfiguration conf

public IReadOnlyCollection<XElement> GetAllElements()
{
var request = new ListObjectsRequest();
request.BucketName = _configuration.BucketName;
var request = new ListObjectsRequest {BucketName = _configuration.BucketName};
var result = _s3Client.ListObjectsAsync(request).Result;
if (result.IsTruncated)
{
Expand All @@ -36,11 +34,13 @@ public IReadOnlyCollection<XElement> GetAllElements()

private XElement GetElement(string key)
{
var request = new GetObjectRequest();
request.BucketName = _configuration.BucketName;
request.Key = key;
var request = new GetObjectRequest
{
BucketName = _configuration.BucketName,
Key = key
};
// Does not support non-async in .NET Core:
var result = _s3Client.GetObjectAsync(request).Result;
XmlDocument document = new XmlDocument();
using (var stream = result.ResponseStream)
{
var xDocument = XDocument.Load(stream);
Expand All @@ -62,6 +62,7 @@ public void StoreElement(XElement element, string friendlyName)
InputStream = memoryStream,
ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256
};
// Does not support non-async in .NET Core:
var result = _s3Client.PutObjectAsync(request).Result;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/S3XmlRepository/S3XmlRepository.xproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ProjectGuid>50956399-40f8-466f-b4d6-c6a435652cd7</ProjectGuid>
<RootNamespace>S3XmlRepository</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
Expand Down
42 changes: 22 additions & 20 deletions src/S3XmlRepository/project.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
{
"copyright": "Chris Close",
"summary": "ASP.NET S3 XmlRepository Implementation",
"description": "An implementation of IXmlRepository for AWS S3 storage for use in ASP.NET Core",
"licenseUrl": "https://opensource.org/licenses/MIT",
"owners": [ "Chris Close" ],
"projectUrl": "https://github.com/CL0SeY/aspnet-s3xmlrepository",
"repository": {
"type": "git",
"url": "https://github.com/CL0SeY/aspnet-s3xmlrepository"
"packOptions": {
"description": "An implementation of IXmlRepository for AWS S3 storage for use in ASP.NET Core",
"summary": "ASP.NET S3 XmlRepository Implementation",
"licenseUrl": "https://opensource.org/licenses/MIT",
"authors": [ "Chris Close" ],
"repository": {
"type": "git",
"url": "https://github.com/CL0SeY/aspnet-s3xmlrepository"
},
"projectUrl": "https://github.com/CL0SeY/aspnet-s3xmlrepository",
"owners": [ "Chris Close" ]
},
"authors": [ "Chris Close" ],
"version": "1.0.1-beta",
"compilationOptions": {
"version": "1.0.2-beta",
"buildOptions": {
"emitEntryPoint": false
},

"dependencies": {
"AWSSDK.S3": "3.2.3-beta",
"Microsoft.AspNet.DataProtection": "1.0.0-rc1-final",
"PCLCrypto": "2.0.147",
"System.Linq": "4.0.1-beta-23516"
},

"commands": {
"AWSSDK.S3": "3.2.6-beta",
"Microsoft.AspNetCore.DataProtection": "1.0.0",
"PCLCrypto": "2.0.147"
},

"frameworks": {
"net451": {
"dependencies": {
}
},
"dotnet5.4": {
"netstandard1.6": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
],
"dependencies": {
"System.Xml.XmlDocument": "4.0.1-beta-23516"
"NETStandard.Library": "1.6.0"
}
}
}
Expand Down
Loading

0 comments on commit b7f732c

Please sign in to comment.