Skip to content

Commit 52f2579

Browse files
committed
Extended, where possible to .NET Standard 1.3.
Consolidated support to .NET Standard 2.0
1 parent 875b85d commit 52f2579

28 files changed

Lines changed: 96 additions & 130 deletions

File tree

SharpRepository.AzureBlobRepository/SharpRepository.AzureBlobRepository.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
3-
<TargetFramework>netstandard1.5</TargetFramework>
3+
<TargetFrameworks>netstandard1.3;netstandard1.5;netstandard1.6;netstandard2.0</TargetFrameworks>
44
<Product>SharpRepository for AzureBlob</Product>
55
<Authors>Ben Griswold, Jeff Treuting</Authors>
66
<Description>SharpRepository is a generic repository</Description>
@@ -17,17 +17,14 @@
1717
<RepositoryType>git</RepositoryType>
1818
<Version>2.0.0-alpha2</Version>
1919
<FileVersion>2.0.0.0</FileVersion>
20-
2120
</PropertyGroup>
2221
<ItemGroup>
2322
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />
2423
</ItemGroup>
2524
<ItemGroup>
2625
<Folder Include="Properties\" />
27-
<Folder Include="Properties\" />
28-
<Folder Include="Properties\" />
2926
</ItemGroup>
3027
<ItemGroup>
31-
<PackageReference Include="WindowsAzure.Storage" Version="8.2.1" />
28+
<PackageReference Include="WindowsAzure.Storage" Version="8.4.0" />
3229
</ItemGroup>
3330
</Project>

SharpRepository.AzureDocumentDb/SharpRepository.AzureDocumentDb.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
3-
<TargetFramework>netstandard1.5</TargetFramework>
3+
<TargetFrameworks>netstandard1.5;netstandard1.6;netstandard2.0</TargetFrameworks>
44
<Product>SharpRepository for AzureDocumentDb</Product>
55
<Authors>Ben Griswold, Jeff Treuting</Authors>
66
<Description>SharpRepository is a generic repository</Description>
@@ -17,15 +17,12 @@
1717
<RepositoryType>git</RepositoryType>
1818
<Version>2.0.0-alpha2</Version>
1919
<FileVersion>2.0.0.0</FileVersion>
20-
2120
</PropertyGroup>
2221
<ItemGroup>
2322
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />
2423
</ItemGroup>
2524
<ItemGroup>
2625
<Folder Include="Properties\" />
27-
<Folder Include="Properties\" />
28-
<Folder Include="Properties\" />
2926
</ItemGroup>
3027
<ItemGroup>
3128
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="1.4.0" />

SharpRepository.AzureTableRepository/SharpRepository.AzureTableRepository.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
22
<PropertyGroup>
3-
<TargetFramework>netstandard1.5</TargetFramework>
3+
<TargetFrameworks>netstandard1.5;netstandard1.6;netstandard2.0</TargetFrameworks>
44
<Product>SharpRepository for AzureTable</Product>
55
<Authors>Ben Griswold, Jeff Treuting</Authors>
66
<Description>SharpRepository is a generic repository</Description>
@@ -17,19 +17,17 @@
1717
<RepositoryType>git</RepositoryType>
1818
<Version>2.0.0-alpha2</Version>
1919
<FileVersion>2.0.0.0</FileVersion>
20-
2120
</PropertyGroup>
2221
<ItemGroup>
2322
<PackageReference Include="Microsoft.Azure.KeyVault" Version="2.3.2" />
23+
<PackageReference Include="WindowsAzure.Storage" Version="8.4.0" />
2424
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
2525
<PackageReference Include="Remotion.Linq" Version="2.1.2" />
26-
<PackageReference Include="WindowsAzure.Storage" Version="8.2.1" />
2726
</ItemGroup>
2827
<ItemGroup>
2928
<ProjectReference Include="..\SharpRepository.Repository\SharpRepository.Repository.csproj" />
3029
</ItemGroup>
3130
<ItemGroup>
3231
<Folder Include="Properties\" />
33-
<Folder Include="Properties\" />
3432
</ItemGroup>
3533
</Project>

SharpRepository.CacheRepository/CacheCompoundKeyRepositoryBase.cs

Lines changed: 25 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ protected override IQueryable<T> BaseQuery(IFetchStrategy<T> fetchStrategy = nul
5555

5656
protected override T GetQuery(params object[] keys)
5757
{
58-
T result;
59-
Items.TryGetValue(String.Join("/", keys), out result);
58+
Items.TryGetValue(String.Join("/", keys), out T result);
6059

6160
return result;
6261
}
@@ -66,8 +65,8 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<string, T> li
6665
// when you Google deep copy of generic list every answer uses either the IClonable interface on the T or having the T be Serializable
6766
// since we can't really put those constraints on T I'm going to do it via reflection
6867

69-
var type = typeof(T);
70-
var properties = type.GetTypeInfo().GetProperties();
68+
Type type = typeof(T);
69+
var properties = type.GetTypeInfo().DeclaredProperties;
7170

7271
var clonedList = new List<T>(list.Count);
7372

@@ -87,9 +86,7 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<string, T> li
8786

8887
protected override void AddItem(T entity)
8988
{
90-
object[] keys;
91-
92-
if (!GetPrimaryKeys(entity, out keys))
89+
if (!GetPrimaryKeys(entity, out object[] keys))
9390
{
9491
throw new ArgumentException("Primary keys not set");
9592
}
@@ -99,22 +96,17 @@ protected override void AddItem(T entity)
9996

10097
protected override void DeleteItem(T entity)
10198
{
102-
object[] keys;
103-
104-
if (!GetPrimaryKeys(entity, out keys))
99+
if (!GetPrimaryKeys(entity, out object[] keys))
105100
{
106101
throw new ArgumentException("Primary keys not set");
107102
}
108103

109-
T tmp;
110-
Items.TryRemove(String.Join("/", keys), out tmp);
104+
Items.TryRemove(String.Join("/", keys), out T tmp);
111105
}
112106

113107
protected override void UpdateItem(T entity)
114108
{
115-
object[] keys;
116-
117-
if (!GetPrimaryKeys(entity, out keys))
109+
if (!GetPrimaryKeys(entity, out object[] keys))
118110
{
119111
throw new ArgumentException("Primary keys not set");
120112
}
@@ -124,12 +116,10 @@ protected override void UpdateItem(T entity)
124116

125117
protected override void SaveChanges()
126118
{
127-
128119
}
129120

130121
public override void Dispose()
131122
{
132-
133123
}
134124

135125
public override string ToString()
@@ -152,10 +142,8 @@ public override int GetHashCode()
152142

153143
public override bool Equals(object obj)
154144
{
155-
if (obj is CompoundKey)
145+
if (obj is CompoundKey compositeKey)
156146
{
157-
var compositeKey = (CompoundKey)obj;
158-
159147
return Key1.Equals(compositeKey.Key1) && Key2.Equals(compositeKey.Key2);
160148
}
161149

@@ -207,9 +195,8 @@ protected override IQueryable<T> BaseQuery(IFetchStrategy<T> fetchStrategy = nul
207195

208196
protected override T GetQuery(TKey key, TKey2 key2)
209197
{
210-
T result;
211198
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2 };
212-
Items.TryGetValue(compoundKey, out result);
199+
Items.TryGetValue(compoundKey, out T result);
213200

214201
return result;
215202
}
@@ -240,43 +227,34 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<CompoundKey,
240227

241228
protected override void AddItem(T entity)
242229
{
243-
TKey key;
244-
TKey2 key2;
245-
GetPrimaryKey(entity, out key, out key2);
230+
GetPrimaryKey(entity, out TKey key, out TKey2 key2);
246231

247232
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2 };
248233
Items[compoundKey] = entity;
249234
}
250235

251236
protected override void DeleteItem(T entity)
252237
{
253-
TKey key;
254-
TKey2 key2;
255-
GetPrimaryKey(entity, out key, out key2);
238+
GetPrimaryKey(entity, out TKey key, out TKey2 key2);
256239

257-
T tmp;
258240
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2 };
259-
Items.TryRemove(compoundKey, out tmp);
241+
Items.TryRemove(compoundKey, out T tmp);
260242
}
261243

262244
protected override void UpdateItem(T entity)
263245
{
264-
TKey key;
265-
TKey2 key2;
266-
GetPrimaryKey(entity, out key, out key2);
246+
GetPrimaryKey(entity, out TKey key, out TKey2 key2);
267247

268248
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2 };
269249
Items[compoundKey] = entity;
270250
}
271251

272252
protected override void SaveChanges()
273253
{
274-
275254
}
276255

277256
public override void Dispose()
278257
{
279-
280258
}
281259

282260
public override string ToString()
@@ -301,10 +279,8 @@ public override int GetHashCode()
301279

302280
public override bool Equals(object obj)
303281
{
304-
if (obj is CompoundKey)
282+
if (obj is CompoundKey compositeKey)
305283
{
306-
var compositeKey = (CompoundKey)obj;
307-
308284
return Key1.Equals(compositeKey.Key1) && Key2.Equals(compositeKey.Key2) && Key3.Equals(compositeKey.Key2);
309285
}
310286

@@ -356,9 +332,8 @@ protected override IQueryable<T> BaseQuery(IFetchStrategy<T> fetchStrategy = nul
356332

357333
protected override T GetQuery(TKey key, TKey2 key2, TKey3 key3)
358334
{
359-
T result;
360335
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
361-
Items.TryGetValue(compoundKey, out result);
336+
Items.TryGetValue(compoundKey, out T result);
362337

363338
return result;
364339
}
@@ -389,46 +364,34 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<CompoundKey,
389364

390365
protected override void AddItem(T entity)
391366
{
392-
TKey key;
393-
TKey2 key2;
394-
TKey3 key3;
395-
GetPrimaryKey(entity, out key, out key2, out key3);
367+
GetPrimaryKey(entity, out TKey key, out TKey2 key2, out TKey3 key3);
396368

397369
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
398370
Items[compoundKey] = entity;
399371
}
400372

401373
protected override void DeleteItem(T entity)
402374
{
403-
TKey key;
404-
TKey2 key2;
405-
TKey3 key3;
406-
GetPrimaryKey(entity, out key, out key2, out key3);
375+
GetPrimaryKey(entity, out TKey key, out TKey2 key2, out TKey3 key3);
407376

408-
T tmp;
409377
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
410-
Items.TryRemove(compoundKey, out tmp);
378+
Items.TryRemove(compoundKey, out T tmp);
411379
}
412380

413381
protected override void UpdateItem(T entity)
414382
{
415-
TKey key;
416-
TKey2 key2;
417-
TKey3 key3;
418-
GetPrimaryKey(entity, out key, out key2, out key3);
383+
GetPrimaryKey(entity, out TKey key, out TKey2 key2, out TKey3 key3);
419384

420385
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
421386
Items[compoundKey] = entity;
422387
}
423388

424389
protected override void SaveChanges()
425390
{
426-
427391
}
428392

429393
public override void Dispose()
430394
{
431-
432395
}
433396

434397
public override string ToString()
@@ -453,10 +416,8 @@ public override int GetHashCode()
453416

454417
public override bool Equals(object obj)
455418
{
456-
if (obj is CompoundKey)
419+
if (obj is CompoundKey compositeKey)
457420
{
458-
var compositeKey = (CompoundKey)obj;
459-
460421
return Key1.Equals(compositeKey.Key1) && Key2.Equals(compositeKey.Key2) && Key3.Equals(compositeKey.Key3);
461422
}
462423

@@ -478,9 +439,8 @@ protected override IQueryable<T> BaseQuery(IFetchStrategy<T> fetchStrategy = nul
478439

479440
protected override T GetQuery(TKey key, TKey2 key2, TKey3 key3)
480441
{
481-
T result;
482442
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
483-
_items.TryGetValue(compoundKey, out result);
443+
_items.TryGetValue(compoundKey, out T result);
484444

485445
return result;
486446
}
@@ -492,7 +452,6 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<CompoundKey,
492452

493453
var type = typeof(T);
494454
var properties = type.GetProperties();
495-
496455
var clonedList = new List<T>(list.Count);
497456

498457
foreach (var keyValuePair in list)
@@ -511,47 +470,34 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<CompoundKey,
511470

512471
protected override void AddItem(T entity)
513472
{
514-
TKey key;
515-
TKey2 key2;
516-
TKey3 key3;
517-
518-
GetPrimaryKey(entity, out key, out key2, out key3);
473+
GetPrimaryKey(entity, out TKey key, out TKey2 key2, out TKey3 key3);
519474

520475
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
521476
_items[compoundKey] = entity;
522477
}
523478

524479
protected override void DeleteItem(T entity)
525480
{
526-
TKey key;
527-
TKey2 key2;
528-
TKey3 key3;
529-
GetPrimaryKey(entity, out key, out key2, out key3);
481+
GetPrimaryKey(entity, out TKey key, out TKey2 key2, out TKey3 key3);
530482

531-
T tmp;
532483
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
533-
_items.TryRemove(compoundKey, out tmp);
484+
_items.TryRemove(compoundKey, out T tmp);
534485
}
535486

536487
protected override void UpdateItem(T entity)
537488
{
538-
TKey key;
539-
TKey2 key2;
540-
TKey3 key3;
541-
GetPrimaryKey(entity, out key, out key2, out key3);
489+
GetPrimaryKey(entity, out TKey key, out TKey2 key2, out TKey3 key3);
542490

543491
var compoundKey = new CompoundKey { Key1 = key, Key2 = key2, Key3 = key3 };
544492
_items[compoundKey] = entity;
545493
}
546494

547495
protected override void SaveChanges()
548496
{
549-
550497
}
551498

552499
public override void Dispose()
553500
{
554-
555501
}
556502

557503
public override string ToString()

SharpRepository.CacheRepository/CacheRepositoryBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static IEnumerable<T> CloneDictionary(ConcurrentDictionary<TKey, T> list
6666
// since we can't really put those constraints on T I'm going to do it via reflection
6767

6868
var type = typeof(T);
69-
var properties = type.GetTypeInfo().GetProperties();
69+
var properties = type.GetTypeInfo().DeclaredProperties;
7070

7171
var clonedList = new List<T>(list.Count);
7272

0 commit comments

Comments
 (0)