Skip to content

Commit e5944e9

Browse files
committed
Use the latest csharp version and implement its file-scoped namespaces feature
1 parent eee3e64 commit e5944e9

72 files changed

Lines changed: 3073 additions & 3142 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.

‎common.props‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<Authors>Dmitry Sikorsky</Authors>
55
<Copyright>Copyright © 2015 Dmitry Sikorsky</Copyright>
66
<VersionPrefix>8.1.0</VersionPrefix>
7-
<LangVersion>8.0</LangVersion>
7+
<LangVersion>latest</LangVersion>
88
<PackageIcon>icon.png</PackageIcon>
9-
<PackageProjectUrl>https://extcore.net/</PackageProjectUrl>
9+
<PackageProjectUrl>https://extcore.net</PackageProjectUrl>
1010
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
11+
<RepositoryType>git</RepositoryType>
12+
<RepositoryUrl>https://github.com/ExtCore/ExtCore</RepositoryUrl>
1113
</PropertyGroup>
1214

1315
<ItemGroup>
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
// Copyright © 2015 Dmitry Sikorsky. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
namespace ExtCore.Data.Abstractions
4+
namespace ExtCore.Data.Abstractions;
5+
6+
/// <summary>
7+
/// Describes a repository for working with the underlying storage context.
8+
/// </summary>
9+
public interface IRepository
510
{
611
/// <summary>
7-
/// Describes a repository for working with the underlying storage context.
12+
/// Sets the storage context to work with.
813
/// </summary>
9-
public interface IRepository
10-
{
11-
/// <summary>
12-
/// Sets the storage context to work with.
13-
/// </summary>
14-
/// <param name="storageContext">The storage context to set.</param>
15-
void SetStorageContext(IStorageContext storageContext);
16-
}
14+
/// <param name="storageContext">The storage context to set.</param>
15+
void SetStorageContext(IStorageContext storageContext);
1716
}

‎src/ExtCore.Data.Abstractions/IStorage.cs‎

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,34 @@
33

44
using System.Threading.Tasks;
55

6-
namespace ExtCore.Data.Abstractions
6+
namespace ExtCore.Data.Abstractions;
7+
8+
/// <summary>
9+
/// Describes a storage that is implementation of the Unit of Work design pattern with the mechanism
10+
/// of getting the repositories to work with the underlying storage context and committing the changes
11+
/// made by all the repositories.
12+
/// </summary>
13+
public interface IStorage
714
{
815
/// <summary>
9-
/// Describes a storage that is implementation of the Unit of Work design pattern with the mechanism
10-
/// of getting the repositories to work with the underlying storage context and committing the changes
11-
/// made by all the repositories.
16+
/// Gets the underlying storage context used by this storage.
1217
/// </summary>
13-
public interface IStorage
14-
{
15-
/// <summary>
16-
/// Gets the underlying storage context used by this storage.
17-
/// </summary>
18-
IStorageContext StorageContext { get; }
18+
IStorageContext StorageContext { get; }
1919

20-
/// <summary>
21-
/// Gets a repository of the given type.
22-
/// </summary>
23-
/// <typeparam name="T">The type parameter to find implementation of.</typeparam>
24-
/// <returns></returns>
25-
T GetRepository<T>() where T: IRepository;
20+
/// <summary>
21+
/// Gets a repository of the given type.
22+
/// </summary>
23+
/// <typeparam name="T">The type parameter to find implementation of.</typeparam>
24+
/// <returns></returns>
25+
T GetRepository<T>() where T: IRepository;
2626

27-
/// <summary>
28-
/// Commits the changes made by all the repositories.
29-
/// </summary>
30-
int Save();
27+
/// <summary>
28+
/// Commits the changes made by all the repositories.
29+
/// </summary>
30+
int Save();
3131

32-
/// <summary>
33-
/// Asynchronously commits the changes made by all the repositories.
34-
/// </summary>
35-
Task<int> SaveAsync();
36-
}
32+
/// <summary>
33+
/// Asynchronously commits the changes made by all the repositories.
34+
/// </summary>
35+
Task<int> SaveAsync();
3736
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Copyright © 2015 Dmitry Sikorsky. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4-
namespace ExtCore.Data.Abstractions
4+
namespace ExtCore.Data.Abstractions;
5+
6+
/// <summary>
7+
/// Describes a storage context that must be shared among all the repositories. Storage context
8+
/// represents concrete storage (for example, SQLite database).
9+
/// </summary>
10+
public interface IStorageContext
511
{
6-
/// <summary>
7-
/// Describes a storage context that must be shared among all the repositories. Storage context
8-
/// represents concrete storage (for example, SQLite database).
9-
/// </summary>
10-
public interface IStorageContext
11-
{
12-
}
1312
}

‎src/ExtCore.Data.Dapper.MySql/StorageContext.cs‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33

44
using Microsoft.Extensions.Options;
55

6-
namespace ExtCore.Data.Dapper.MySql
6+
namespace ExtCore.Data.Dapper.MySql;
7+
8+
/// <summary>
9+
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents MySQL database
10+
/// with the Dapper as the ORM.
11+
/// </summary>
12+
public class StorageContext : StorageContextBase
713
{
814
/// <summary>
9-
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents MySQL database
10-
/// with the Dapper as the ORM.
15+
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
1116
/// </summary>
12-
public class StorageContext : StorageContextBase
17+
/// <param name="options">The options that are used to connect to the MySQL database.</param>
18+
public StorageContext(IOptions<StorageContextOptions> options)
19+
: base(options)
1320
{
14-
/// <summary>
15-
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
16-
/// </summary>
17-
/// <param name="options">The options that are used to connect to the MySQL database.</param>
18-
public StorageContext(IOptions<StorageContextOptions> options)
19-
: base(options)
20-
{
21-
}
2221
}
2322
}

‎src/ExtCore.Data.Dapper.PostgreSql/StorageContext.cs‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33

44
using Microsoft.Extensions.Options;
55

6-
namespace ExtCore.Data.Dapper.PostgreSql
6+
namespace ExtCore.Data.Dapper.PostgreSql;
7+
8+
/// <summary>
9+
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents PostgreSQL database
10+
/// with the Dapper as the ORM.
11+
/// </summary>
12+
public class StorageContext : StorageContextBase
713
{
814
/// <summary>
9-
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents PostgreSQL database
10-
/// with the Dapper as the ORM.
15+
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
1116
/// </summary>
12-
public class StorageContext : StorageContextBase
17+
/// <param name="options">The options that are used to connect to the PostgreSQL database.</param>
18+
public StorageContext(IOptions<StorageContextOptions> options)
19+
: base(options)
1320
{
14-
/// <summary>
15-
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
16-
/// </summary>
17-
/// <param name="options">The options that are used to connect to the PostgreSQL database.</param>
18-
public StorageContext(IOptions<StorageContextOptions> options)
19-
: base(options)
20-
{
21-
}
2221
}
2322
}

‎src/ExtCore.Data.Dapper.SqlServer/StorageContext.cs‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33

44
using Microsoft.Extensions.Options;
55

6-
namespace ExtCore.Data.Dapper.SqlServer
6+
namespace ExtCore.Data.Dapper.SqlServer;
7+
8+
/// <summary>
9+
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents SQL Server database
10+
/// with the Dapper as the ORM.
11+
/// </summary>
12+
public class StorageContext : StorageContextBase
713
{
814
/// <summary>
9-
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents SQL Server database
10-
/// with the Dapper as the ORM.
15+
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
1116
/// </summary>
12-
public class StorageContext : StorageContextBase
17+
/// <param name="options">The options that are used to connect to the SQL Server database.</param>
18+
public StorageContext(IOptions<StorageContextOptions> options)
19+
: base(options)
1320
{
14-
/// <summary>
15-
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
16-
/// </summary>
17-
/// <param name="options">The options that are used to connect to the SQL Server database.</param>
18-
public StorageContext(IOptions<StorageContextOptions> options)
19-
: base(options)
20-
{
21-
}
2221
}
2322
}

‎src/ExtCore.Data.Dapper.Sqlite/StorageContext.cs‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33

44
using Microsoft.Extensions.Options;
55

6-
namespace ExtCore.Data.Dapper.Sqlite
6+
namespace ExtCore.Data.Dapper.Sqlite;
7+
8+
/// <summary>
9+
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents SQLite database
10+
/// with the Dapper as the ORM.
11+
/// </summary>
12+
public class StorageContext : StorageContextBase
713
{
814
/// <summary>
9-
/// Implements the <see cref="IStorageContext">IStorageContext</see> interface and represents SQLite database
10-
/// with the Dapper as the ORM.
15+
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
1116
/// </summary>
12-
public class StorageContext : StorageContextBase
17+
/// <param name="options">The options that are used to connect to the SQLite database.</param>
18+
public StorageContext(IOptions<StorageContextOptions> options)
19+
: base(options)
1320
{
14-
/// <summary>
15-
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
16-
/// </summary>
17-
/// <param name="options">The options that are used to connect to the SQLite database.</param>
18-
public StorageContext(IOptions<StorageContextOptions> options)
19-
: base(options)
20-
{
21-
}
2221
}
2322
}

‎src/ExtCore.Data.Dapper/Actions/AddStorageContextAction.cs‎

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,40 @@
1010
using Microsoft.Extensions.DependencyInjection;
1111
using Microsoft.Extensions.Logging;
1212

13-
namespace ExtCore.Data.Dapper.Actions
13+
namespace ExtCore.Data.Dapper.Actions;
14+
15+
/// <summary>
16+
/// Implements the <see cref="IConfigureServicesAction">IConfigureServicesAction</see> interface and
17+
/// registers found implementation of the <see cref="IStorageContext">IStorageContext</see> interface inside the DI.
18+
/// </summary>
19+
public class AddStorageContextAction : IConfigureServicesAction
1420
{
1521
/// <summary>
16-
/// Implements the <see cref="IConfigureServicesAction">IConfigureServicesAction</see> interface and
17-
/// registers found implementation of the <see cref="IStorageContext">IStorageContext</see> interface inside the DI.
22+
/// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
23+
/// </summary>
24+
public int Priority => 1000;
25+
26+
/// <summary>
27+
/// Registers found implementation of the <see cref="IStorageContext">IStorageContext</see> interface inside the DI.
1828
/// </summary>
19-
public class AddStorageContextAction : IConfigureServicesAction
29+
/// <param name="services">
30+
/// Will be provided by the ExtCore and might be used to register any service inside the DI.
31+
/// </param>
32+
/// <param name="serviceProvider">
33+
/// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
34+
/// </param>
35+
public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
2036
{
21-
/// <summary>
22-
/// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
23-
/// </summary>
24-
public int Priority => 1000;
37+
Type type = ExtensionManager.GetImplementations<IStorageContext>()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
2538

26-
/// <summary>
27-
/// Registers found implementation of the <see cref="IStorageContext">IStorageContext</see> interface inside the DI.
28-
/// </summary>
29-
/// <param name="services">
30-
/// Will be provided by the ExtCore and might be used to register any service inside the DI.
31-
/// </param>
32-
/// <param name="serviceProvider">
33-
/// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
34-
/// </param>
35-
public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
39+
if (type == null)
3640
{
37-
Type type = ExtensionManager.GetImplementations<IStorageContext>()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
41+
ILogger logger = serviceProvider.GetService<ILoggerFactory>().CreateLogger("ExtCore.Data.Dapper");
3842

39-
if (type == null)
40-
{
41-
ILogger logger = serviceProvider.GetService<ILoggerFactory>().CreateLogger("ExtCore.Data.Dapper");
42-
43-
logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorageContext not found");
44-
return;
45-
}
46-
47-
services.AddScoped(typeof(IStorageContext), type);
43+
logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorageContext not found");
44+
return;
4845
}
46+
47+
services.AddScoped(typeof(IStorageContext), type);
4948
}
5049
}

‎src/ExtCore.Data.Dapper/Extension.cs‎

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,31 @@
33

44
using ExtCore.Infrastructure;
55

6-
namespace ExtCore.Data.Dapper
6+
namespace ExtCore.Data.Dapper;
7+
8+
/// <summary>
9+
/// Overrides the <see cref="ExtensionBase">ExtensionBase</see> class and provides the
10+
/// ExtCore.Data.Dapper extension information.
11+
/// </summary>
12+
public class Extension : ExtensionBase
713
{
814
/// <summary>
9-
/// Overrides the <see cref="ExtensionBase">ExtensionBase</see> class and provides the
10-
/// ExtCore.Data.Dapper extension information.
15+
/// Gets the name of the extension.
1116
/// </summary>
12-
public class Extension : ExtensionBase
13-
{
14-
/// <summary>
15-
/// Gets the name of the extension.
16-
/// </summary>
17-
public override string Name => "ExtCore.Data.Dapper";
17+
public override string Name => "ExtCore.Data.Dapper";
1818

19-
/// <summary>
20-
/// Gets the URL of the extension.
21-
/// </summary>
22-
public override string Url => "https://extcore.net/";
19+
/// <summary>
20+
/// Gets the URL of the extension.
21+
/// </summary>
22+
public override string Url => "https://extcore.net/";
2323

24-
/// <summary>
25-
/// Gets the version of the extension.
26-
/// </summary>
27-
public override string Version => "8.1.0";
24+
/// <summary>
25+
/// Gets the version of the extension.
26+
/// </summary>
27+
public override string Version => "8.1.0";
2828

29-
/// <summary>
30-
/// Gets the authors of the extension (separated by commas).
31-
/// </summary>
32-
public override string Authors => "Dmitry Sikorsky";
33-
}
29+
/// <summary>
30+
/// Gets the authors of the extension (separated by commas).
31+
/// </summary>
32+
public override string Authors => "Dmitry Sikorsky";
3433
}

0 commit comments

Comments
 (0)