Skip to content

Commit ec8dcc2

Browse files
committed
refactoring
1 parent 52f5b88 commit ec8dcc2

File tree

57 files changed

+534
-649
lines changed

Some content is hidden

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

57 files changed

+534
-649
lines changed

.github/workflows/nuget.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: nuget
33
on:
44
push:
55
branches: [ main ]
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
69

710
jobs:
811
nuget-pack:
@@ -21,7 +24,7 @@ jobs:
2124
- name: Build
2225
run: dotnet build --configuration Release
2326
- name: Pack
24-
run: dotnet pack --configuration Release
27+
run: dotnet pack -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg --configuration Release
2528

2629
- name: publish nuget packages
2730
run: |

Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
1919
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
2020
</PropertyGroup>
21+
<PropertyGroup>
22+
<IncludeSymbols>true</IncludeSymbols>
23+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
24+
</PropertyGroup>
2125
<ItemGroup>
2226
<None Include="$(SolutionDir)\logo.png" Pack="true" Visible="false" PackagePath="" />
2327
</ItemGroup>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using ManagedCode.Database.Core;
6+
using ManagedCode.Database.Core.Common;
7+
using ManagedCode.Database.Core.InMemory;
8+
using Microsoft.Azure.Cosmos.Table;
9+
10+
namespace ManagedCode.Database.AzureTable;
11+
12+
public class AzureDatabase : BaseDatabase, IDatabase<CloudTableClient>
13+
{
14+
private readonly AzureTableRepositoryOptions _options;
15+
private Dictionary<string, object> tableAdapters = new();
16+
public AzureDatabase(AzureTableRepositoryOptions options)
17+
{
18+
_options = options;
19+
IsInitialized = true;
20+
}
21+
protected override Task InitializeAsyncInternal(CancellationToken token = default)
22+
{
23+
return Task.CompletedTask;
24+
}
25+
26+
protected override ValueTask DisposeAsyncInternal()
27+
{
28+
DisposeInternal();
29+
return new ValueTask(Task.CompletedTask);
30+
}
31+
32+
protected override void DisposeInternal()
33+
{
34+
tableAdapters.Clear();
35+
}
36+
37+
public AzureTableDBCollection<TItem> GetCollection<TId, TItem>() where TItem : AzureTableItem, IItem<TId>, new()
38+
{
39+
return GetCollection<TId, TItem>(typeof(TItem).FullName);
40+
}
41+
42+
public AzureTableDBCollection<TItem> GetCollection<TId, TItem>(string name) where TItem : AzureTableItem, IItem<TId>, new()
43+
{
44+
if (!IsInitialized)
45+
{
46+
throw new DatabaseNotInitializedException(GetType());
47+
}
48+
49+
lock (tableAdapters)
50+
{
51+
if (tableAdapters.TryGetValue(name, out var table))
52+
{
53+
return (AzureTableDBCollection<TItem>)table;
54+
}
55+
56+
AzureTableAdapter<TItem> tableAdapter;
57+
if (string.IsNullOrEmpty(_options.ConnectionString))
58+
{
59+
tableAdapter = new AzureTableAdapter<TItem>(Logger, _options.TableStorageCredentials, _options.TableStorageUri);
60+
}
61+
else
62+
{
63+
tableAdapter = new AzureTableAdapter<TItem>(Logger, _options.ConnectionString);
64+
}
65+
66+
var collection = new AzureTableDBCollection<TItem>(tableAdapter);
67+
68+
tableAdapters[name] = collection;
69+
return collection;
70+
}
71+
}
72+
73+
public override Task Delete(CancellationToken token = default)
74+
{
75+
throw new NotImplementedException();
76+
}
77+
78+
public CloudTableClient DataBase { get; }
79+
}

ManagedCode.Database.AzureTable/BaseAzureTableRepository.cs renamed to ManagedCode.Database.AzureTable/AzureTableDBCollection.cs

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,10 @@
55
using System.Threading;
66
using System.Threading.Tasks;
77
using ManagedCode.Database.Core;
8-
using ManagedCode.Database.Core.Common;
9-
using ManagedCode.Database.Core.InMemory;
108
using Microsoft.Azure.Cosmos.Table;
119

1210
namespace ManagedCode.Database.AzureTable;
1311

14-
public class AzureDatabase : BaseDatabase, IDatabase<CloudTableClient>
15-
{
16-
private readonly AzureTableRepositoryOptions _options;
17-
private Dictionary<string, object> tableAdapters = new();
18-
public AzureDatabase(AzureTableRepositoryOptions options)
19-
{
20-
_options = options;
21-
IsInitialized = true;
22-
}
23-
protected override Task InitializeAsyncInternal(CancellationToken token = default)
24-
{
25-
return Task.CompletedTask;
26-
}
27-
28-
protected override ValueTask DisposeAsyncInternal()
29-
{
30-
DisposeInternal();
31-
return new ValueTask(Task.CompletedTask);
32-
}
33-
34-
protected override void DisposeInternal()
35-
{
36-
tableAdapters.Clear();
37-
}
38-
39-
public AzureTableDBCollection<TItem> GetCollection<TId, TItem>() where TItem : AzureTableItem, IItem<TId>, new()
40-
{
41-
return GetCollection<TId, TItem>(typeof(TItem).FullName);
42-
}
43-
44-
public AzureTableDBCollection<TItem> GetCollection<TId, TItem>(string name) where TItem : AzureTableItem, IItem<TId>, new()
45-
{
46-
if (!IsInitialized)
47-
{
48-
throw new DatabaseNotInitializedException(GetType());
49-
}
50-
51-
lock (tableAdapters)
52-
{
53-
if (tableAdapters.TryGetValue(name, out var table))
54-
{
55-
return (AzureTableDBCollection<TItem>)table;
56-
}
57-
58-
AzureTableAdapter<TItem> tableAdapter;
59-
if (string.IsNullOrEmpty(_options.ConnectionString))
60-
{
61-
tableAdapter = new AzureTableAdapter<TItem>(Logger, _options.TableStorageCredentials, _options.TableStorageUri);
62-
}
63-
else
64-
{
65-
tableAdapter = new AzureTableAdapter<TItem>(Logger, _options.ConnectionString);
66-
}
67-
68-
var collection = new AzureTableDBCollection<TItem>(tableAdapter);
69-
70-
tableAdapters[name] = collection;
71-
return collection;
72-
}
73-
}
74-
75-
public override Task Delete(CancellationToken token = default)
76-
{
77-
throw new NotImplementedException();
78-
}
79-
80-
public CloudTableClient DataBase { get; }
81-
}
82-
8312
public class AzureTableDBCollection<TItem> : BaseDBCollection<TableId, TItem>
8413
where TItem : AzureTableItem, new()
8514
{

ManagedCode.Database.AzureTable/IAzureTableRepository.cs renamed to ManagedCode.Database.AzureTable/IAzureDBCollection.cs

File renamed without changes.

ManagedCode.Database.Core/Common/RepositoryNotInitializedException.cs renamed to ManagedCode.Database.Core/Common/DatabaseNotInitializedException.cs

File renamed without changes.

ManagedCode.Database.Core/IDBCollection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public interface IDBCollection<in TId, TItem> : IDisposable, IAsyncDisposable wh
2222
Task<int> DeleteAsync(IEnumerable<TId> ids, CancellationToken token = default);
2323
Task<int> DeleteAsync(IEnumerable<TItem> items, CancellationToken token = default);
2424
Task<int> DeleteAsync(Expression<Func<TItem, bool>> predicate, CancellationToken token = default);
25+
2526
Task<bool> DeleteAllAsync(CancellationToken token = default);
2627

2728
Task<TItem> GetAsync(TId id, CancellationToken token = default);

ManagedCode.Database.Core/ManagedCode.Database.Core.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@
2424
</ItemGroup>
2525

2626

27+
<ItemGroup>
28+
<Folder Include="Queries" />
29+
</ItemGroup>
30+
31+
2732
</Project>

ManagedCode.Database.Core/Query.cs

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

ManagedCode.Database.Core/QueryProvider.cs

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

0 commit comments

Comments
 (0)