Skip to content

Commit b356c74

Browse files
committed
Default configurations on packages
Factory for AzureTable Factory for CouchDb Factory for AppFabric cache Factory for WindowsAzure cache
1 parent 629568c commit b356c74

67 files changed

Lines changed: 722 additions & 470 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SharpRepository.AzureBlobRepository/SharpRepository.AzureBlobRepository.csproj

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
33
<TargetFrameworks>netstandard1.3</TargetFrameworks>
4-
<Product>SharpRepository for AzureBlob</Product>
5-
<Authors>Ben Griswold, Jeff Treuting</Authors>
6-
<Description>SharpRepository is a generic repository</Description>
4+
<Product>SharpRepository for AzureBlob</Product>
5+
<Authors>Ben Griswold, Jeff Treuting</Authors>
6+
<Description>SharpRepository is a generic repository, AzureBlob implementation</Description>
77
<Summary>Written in C#, includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits!</Summary>
8-
<PackageId>SharpRepository.AzureBlobRepository</PackageId>
8+
<PackageId>SharpRepository.AzureBlobRepository</PackageId>
99
<PackageVersion>2.0.1-alpha3</PackageVersion>
10-
<PackageReleaseNotes>2.0.1-alpha3: configurable via appsettings.json</PackageReleaseNotes>
11-
<PackageTags>SharpRepository Repository Azure Blob</PackageTags>
12-
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
13-
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
14-
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
15-
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
10+
<PackageReleaseNotes>2.0.1-alpha3: configurable via appsettings.json</PackageReleaseNotes>
11+
<PackageTags>SharpRepository Repository Azure Blob</PackageTags>
12+
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
13+
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
14+
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
15+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1616
<RepositoryUrl>https://github.com/SharpRepository/SharpRepository.git</RepositoryUrl>
17-
<RepositoryType>git</RepositoryType>
18-
<Version>2.0.1-alpha3</Version>
19-
<FileVersion>2.0.1.0</FileVersion>
17+
<RepositoryType>git</RepositoryType>
18+
<Version>2.0.1-alpha3</Version>
2019
</PropertyGroup>
20+
<ItemGroup>
21+
<Content Include="repository.azureBlob.json">
22+
<Pack>true</Pack>
23+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
</Content>
25+
</ItemGroup>
2126
<ItemGroup>
2227
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />
2328
</ItemGroup>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"sharpRepository": {
3+
"repositories": {
4+
"default": "azureBlob",
5+
"azureBlob": {
6+
"factory": "SharpRepository.AzureBlobRepository.AzureBlobConfigRepositoryFactory, SharpRepository.AzureBlobRepository",
7+
"connectionString": "connectionStringOrName",
8+
"container": "containerName",
9+
"createIfNotExists": "true"
10+
}
11+
}
12+
}
13+
}

SharpRepository.AzureDocumentDb/App.config

Lines changed: 0 additions & 11 deletions
This file was deleted.

SharpRepository.AzureDocumentDb/SharpRepository.AzureDocumentDb.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<TargetFrameworks>netstandard1.5</TargetFrameworks>
44
<Product>SharpRepository for AzureDocumentDb</Product>
55
<Authors>Ben Griswold, Jeff Treuting</Authors>
6-
<Description>SharpRepository is a generic repository</Description>
6+
<Description>SharpRepository is a generic repository, Azure DocumentDb implementation</Description>
77
<Summary>Written in C#, includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits!</Summary>
88
<PackageId>SharpRepository.AzureDocumentDbRepository</PackageId>
99
<PackageVersion>2.0.1-alpha3</PackageVersion>
@@ -16,8 +16,13 @@
1616
<RepositoryUrl>https://github.com/SharpRepository/SharpRepository.git</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
1818
<Version>2.0.1-alpha3</Version>
19-
<FileVersion>2.0.0.0</FileVersion>
2019
</PropertyGroup>
20+
<ItemGroup>
21+
<Content Include="repository.azureDocumentDb.json">
22+
<Pack>true</Pack>
23+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
</Content>
25+
</ItemGroup>
2126
<ItemGroup>
2227
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />
2328
</ItemGroup>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"sharpRepository": {
3+
"repositories": {
4+
"default": "azureDocumentDb",
5+
"azureDocumentDb": {
6+
"factory": "SharpRepository.AzureDocumentDbRepository.DocumentDbConfigRepositoryFactory, SharpRepository.AzureDocumentDbRepository",
7+
"endpointUrl": "https://example.com:443/",
8+
"authorizationKey": "DocumentDBSample",
9+
"databaseId": "Entertainment",
10+
"collectionId": "Games",
11+
"createIfNotExists": "true"
12+
}
13+
}
14+
}
15+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using SharpRepository.Repository;
3+
using SharpRepository.Repository.Configuration;
4+
using Microsoft.WindowsAzure.Storage.Table;
5+
6+
namespace SharpRepository.AzureTableRepository
7+
{
8+
public class AzureTableConfigRepositoryFactory : ConfigRepositoryFactory
9+
{
10+
public AzureTableConfigRepositoryFactory(IRepositoryConfiguration config)
11+
: base(config)
12+
{
13+
}
14+
15+
public override IRepository<T> GetInstance<T>()
16+
{
17+
throw new NotImplementedException();
18+
}
19+
20+
public override IRepository<T, TKey> GetInstance<T, TKey>()
21+
{
22+
throw new NotImplementedException("azure table only implements ICompoundKeyRepository<T, string, string> using GetAzureTableInstanc");
23+
}
24+
25+
public override ICompoundKeyRepository<T> GetCompoundKeyInstance<T>()
26+
{
27+
throw new NotImplementedException("azure table only implements ICompoundKeyRepository<T, string, string> using GetAzureTableInstance");
28+
}
29+
30+
public override ICompoundKeyRepository<T, TKey, TKey2, TKey3> GetInstance<T, TKey, TKey2, TKey3>()
31+
{
32+
throw new NotImplementedException("azure table only implements ICompoundKeyRepository<T, TKey, TKey2>");
33+
}
34+
35+
public override ICompoundKeyRepository<T, TKey, TKey2> GetInstance<T, TKey, TKey2>()
36+
{
37+
Boolean.TryParse(RepositoryConfiguration["createIfNotExists"], out bool createIfNotExists);
38+
39+
return new AzureTableRepository<T, TKey, TKey2>(RepositoryConfiguration["connectionString"], RepositoryConfiguration["tableName"], createIfNotExists);
40+
}
41+
}
42+
}
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
using Microsoft.WindowsAzure.Storage.Table;
22
using SharpRepository.Repository.Caching;
3+
using System;
4+
using System.Linq;
5+
using System.Reflection;
36

47
namespace SharpRepository.AzureTableRepository
58
{
6-
public class AzureTableRepository<T> : AzureTableRepositoryBase<T> where T : class, ITableEntity, new()
9+
public class AzureTableRepository<T,TKey, TKey2> : AzureTableRepositoryBase<T, TKey, TKey2> where T : class, new()
710
{
8-
public AzureTableRepository(string connectionString, string tableName = null, bool createIfNotExists = true, ICompoundKeyCachingStrategy<T, string, string> cachingStrategy = null)
11+
public AzureTableRepository(string connectionString, string tableName = null, bool createIfNotExists = true, ICompoundKeyCachingStrategy<T, TKey, TKey2> cachingStrategy = null)
912
: base(connectionString, tableName, createIfNotExists, cachingStrategy)
1013
{
14+
if (typeof(TKey) != typeof(string) && typeof(TKey2) != typeof(string))
15+
{
16+
throw new Exception("Type of keys TKey and TKey2 musts be string");
17+
}
18+
19+
if (!typeof(T).GetTypeInfo().GetInterfaces().Contains(typeof(ITableEntity))) {
20+
throw new Exception("Type of T must implement ITableEntity");
21+
}
1122
}
1223
}
1324
}

SharpRepository.AzureTableRepository/AzureTableRepositoryBase.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
namespace SharpRepository.AzureTableRepository
1010
{
11-
public class AzureTableRepositoryBase<T> : LinqCompoundKeyRepositoryBase<T, string, string> where T : class, ITableEntity, new()
11+
public class AzureTableRepositoryBase<T,TKey,TKey2> : LinqCompoundKeyRepositoryBase<T, TKey, TKey2> where T : class, new()
1212
{
1313
protected CloudTableClient TableClient { get; private set; }
1414
protected CloudTable Table { get; private set; }
1515
protected string TableName { get; private set; }
1616

17-
internal AzureTableRepositoryBase(string connectionString, string tableName, bool createIfNotExists, ICompoundKeyCachingStrategy<T, string, string> cachingStrategy = null)
17+
internal AzureTableRepositoryBase(string connectionString, string tableName, bool createIfNotExists, ICompoundKeyCachingStrategy<T, TKey, TKey2> cachingStrategy = null)
1818
: base(cachingStrategy)
1919
{
2020
var storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(connectionString);
@@ -35,10 +35,13 @@ internal AzureTableRepositoryBase(string connectionString, string tableName, boo
3535
}
3636
}
3737

38-
protected override T GetQuery(string key, string key2)
38+
protected override T GetQuery(TKey key, TKey2 key2)
3939
{
40-
var result = Table.ExecuteAsync(TableOperation.Retrieve<T>(key, key2)).Result;
41-
return result.Result as T;
40+
//TODO: Evaluate if this query without generic type works
41+
var operation = TableOperation.Retrieve(key.ToString(), key2.ToString());
42+
43+
var result = Table.ExecuteAsync(operation).Result;
44+
return result.Result as T;
4245
}
4346

4447
protected override IQueryable<T> BaseQuery(IFetchStrategy<T> fetchStrategy = null)
@@ -48,24 +51,23 @@ protected override IQueryable<T> BaseQuery(IFetchStrategy<T> fetchStrategy = nul
4851

4952
protected override void AddItem(T entity)
5053
{
51-
Table.ExecuteAsync(TableOperation.InsertOrReplace(entity));
54+
Table.ExecuteAsync(TableOperation.InsertOrReplace((ITableEntity)entity));
5255
}
5356

5457
// TODO: override Add(IEnumerable<T> entities) to use the TableSet.Add(entities) isntead of looping ourselves and having AddItem() called multiple times
5558

5659
protected override void DeleteItem(T entity)
5760
{
58-
Table.ExecuteAsync(TableOperation.Delete(entity));
61+
Table.ExecuteAsync(TableOperation.Delete((ITableEntity)entity));
5962
}
6063

6164
protected override void UpdateItem(T entity)
6265
{
63-
Table.ExecuteAsync(TableOperation.Replace(entity));
66+
Table.ExecuteAsync(TableOperation.Replace((ITableEntity)entity));
6467
}
6568

6669
protected override void SaveChanges()
6770
{
68-
6971
}
7072

7173
protected override PropertyInfo[] GetPrimaryKeyPropertyInfo()
@@ -85,7 +87,6 @@ protected override PropertyInfo[] GetPrimaryKeyPropertyInfo()
8587

8688
public override void Dispose()
8789
{
88-
8990
}
9091
}
9192
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using SharpRepository.Repository.Configuration;
3+
4+
namespace SharpRepository.AzureTableRepository
5+
{
6+
public class AzureTableRepositoryConfiguration : RepositoryConfiguration
7+
{
8+
public AzureTableRepositoryConfiguration(string name) : this(name, null, null)
9+
{
10+
}
11+
12+
public AzureTableRepositoryConfiguration(string name, string connectionString)
13+
: this(name, connectionString, null)
14+
{
15+
}
16+
17+
public AzureTableRepositoryConfiguration(string name, string connectionString, string tableName, bool createIfNotExists = false, string cachingStrategy = null, string cachingProvider = null)
18+
: base(name)
19+
{
20+
ConnectionString = connectionString;
21+
TableName = tableName;
22+
CreateIfNotExists = createIfNotExists;
23+
CachingStrategy = cachingStrategy;
24+
CachingProvider = cachingProvider;
25+
Factory = typeof(AzureTableConfigRepositoryFactory);
26+
}
27+
28+
public string ConnectionString
29+
{
30+
set { Attributes["connectionString"] = value; }
31+
}
32+
33+
public string TableName
34+
{
35+
set { Attributes["tableName"] = String.IsNullOrEmpty(value) ? null : value; }
36+
}
37+
38+
public bool CreateIfNotExists
39+
{
40+
set { Attributes["createIfNotExists"] = value.ToString(); }
41+
}
42+
}
43+
}
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
33
<TargetFrameworks>netstandard1.5</TargetFrameworks>
4-
<Product>SharpRepository for AzureTable</Product>
5-
<Authors>Ben Griswold, Jeff Treuting</Authors>
6-
<Description>SharpRepository is a generic repository</Description>
4+
<Product>SharpRepository for AzureTable</Product>
5+
<Authors>Ben Griswold, Jeff Treuting</Authors>
6+
<Description>SharpRepository is a generic repository, Azure Table implementation</Description>
77
<Summary>Written in C#, includes support for various relational, document and object databases including Entity Framework, RavenDB, MongoDB, CouchDB and Db4o. SharpRepository includes Xml and InMemory repository implementations as well. SharpRepository offers built-in caching options for AppFabric, memcached and the standard System.Runtime.Caching. SharpRepository also supports Specifications, FetchStrategies, Batches and Traits!</Summary>
8-
<PackageId>SharpRepository.AzureBlobRepository</PackageId>
8+
<PackageId>SharpRepository.AzureTableRepository</PackageId>
99
<PackageVersion>2.0.1-alpha3</PackageVersion>
10-
<PackageReleaseNotes>2.0.1-alpha3: configurable via appsettings.json</PackageReleaseNotes>
11-
<PackageTags>SharpRepository Repository Azure Table</PackageTags>
12-
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
13-
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
14-
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
15-
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
10+
<PackageReleaseNotes>2.0.1-alpha3: configurable via appsettings.json</PackageReleaseNotes>
11+
<PackageTags>SharpRepository Repository Azure Table</PackageTags>
12+
<PackageIconUrl>https://user-images.githubusercontent.com/6349515/28491142-7b6350c4-6eeb-11e7-9c5b-e3b8ef1e73b8.png</PackageIconUrl>
13+
<PackageProjectUrl>https://github.com/SharpRepository/SharpRepository</PackageProjectUrl>
14+
<PackageLicenseUrl>https://raw.githubusercontent.com/SharpRepository/SharpRepository/master/license.txt</PackageLicenseUrl>
15+
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1616
<RepositoryUrl>https://github.com/SharpRepository/SharpRepository.git</RepositoryUrl>
17-
<RepositoryType>git</RepositoryType>
18-
<Version>2.0.1-alpha3</Version>
17+
<RepositoryType>git</RepositoryType>
18+
<Version>2.0.1-alpha3</Version>
1919
</PropertyGroup>
20+
<ItemGroup>
21+
<Content Include="repository.azureTable.json">
22+
<Pack>true</Pack>
23+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
</Content>
25+
</ItemGroup>
2026
<ItemGroup>
2127
<PackageReference Include="Microsoft.Azure.KeyVault" Version="2.3.2" />
2228
<PackageReference Include="WindowsAzure.Storage" Version="8.4.0" />
@@ -26,7 +32,4 @@
2632
<ItemGroup>
2733
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />
2834
</ItemGroup>
29-
<ItemGroup>
30-
<Folder Include="Properties\" />
31-
</ItemGroup>
3235
</Project>

0 commit comments

Comments
 (0)