diff --git a/ExtCore.sln b/ExtCore.sln
index a5744f8..62e358a 100644
--- a/ExtCore.sln
+++ b/ExtCore.sln
@@ -1,10 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27703.2026
+# Visual Studio Version 17
+VisualStudioVersion = 17.3.32825.248
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.Infrastructure", "src\ExtCore.Infrastructure\ExtCore.Infrastructure.csproj", "{1A7B4E8E-9D6D-4DD2-862D-92A6BDDBC2C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.WebApplication", "src\ExtCore.WebApplication\ExtCore.WebApplication.csproj", "{0F8F961C-2A13-47A2-9EFE-245FBA7A1C89}"
@@ -61,6 +59,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage.Dropbox
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage.FileSystem", "src\ExtCore.FileStorage.FileSystem\ExtCore.FileStorage.FileSystem.csproj", "{2031A605-DB91-4998-94DB-8012C590152B}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage.Azure", "src\ExtCore.FileStorage.Azure\ExtCore.FileStorage.Azure.csproj", "{6BDBDD17-3529-4A03-8DF1-25BEF8577E9B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -155,13 +155,15 @@ Global
{2031A605-DB91-4998-94DB-8012C590152B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2031A605-DB91-4998-94DB-8012C590152B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2031A605-DB91-4998-94DB-8012C590152B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6BDBDD17-3529-4A03-8DF1-25BEF8577E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6BDBDD17-3529-4A03-8DF1-25BEF8577E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6BDBDD17-3529-4A03-8DF1-25BEF8577E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6BDBDD17-3529-4A03-8DF1-25BEF8577E9B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {1A7B4E8E-9D6D-4DD2-862D-92A6BDDBC2C8} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
- {0F8F961C-2A13-47A2-9EFE-245FBA7A1C89} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
{E68DD4A8-1B91-4444-BD2F-4FDDBC69DEF1} = {7EB40884-B578-412E-951F-356BC69088C2}
{64AAD007-11ED-4C0C-93D1-FBE2BEA81493} = {7EB40884-B578-412E-951F-356BC69088C2}
{BD3ADB01-9621-4A50-9D0E-8D4CC88A79D8} = {DD95EC14-4783-4E08-A5EC-6C110DC7FB01}
@@ -169,25 +171,20 @@ Global
{A5B17E64-9C8B-40EB-A4FD-637BB1E1BD05} = {A770A286-2B75-4BF7-8300-24CEC8D072AD}
{0C0A69C5-1036-4925-8063-C8E7F6999287} = {A770A286-2B75-4BF7-8300-24CEC8D072AD}
{4B05A3AC-DCDF-454F-A105-C8DFDBFA5EE1} = {A770A286-2B75-4BF7-8300-24CEC8D072AD}
- {7EB40884-B578-412E-951F-356BC69088C2} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
- {DD95EC14-4783-4E08-A5EC-6C110DC7FB01} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
- {B0915CA5-EB7A-428E-8A6E-344CB8CE5368} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
{3E5C83A3-2C66-4503-A3F8-542854D3D2EF} = {B0915CA5-EB7A-428E-8A6E-344CB8CE5368}
{77F8B77C-440C-48D9-80FA-192FF49283C8} = {A770A286-2B75-4BF7-8300-24CEC8D072AD}
{A97967FC-B333-4C27-BAFE-4369C7695688} = {DD95EC14-4783-4E08-A5EC-6C110DC7FB01}
- {A770A286-2B75-4BF7-8300-24CEC8D072AD} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
{79A8C5FE-94FA-4D60-86C7-016EBF0386B4} = {A770A286-2B75-4BF7-8300-24CEC8D072AD}
{976AD81D-4F7D-4A0C-9A2F-F665566EA5A9} = {8C720480-750C-44C1-945B-961599088853}
{F27A3AE9-718C-4539-B541-4F37D16E4463} = {8C720480-750C-44C1-945B-961599088853}
{7B7A5A6C-DB45-4056-B5C7-4286D16220DE} = {8C720480-750C-44C1-945B-961599088853}
{E588921B-5E74-45E8-841B-2654D2416D9F} = {8C720480-750C-44C1-945B-961599088853}
{693AB050-3305-471C-90C3-816BD694A930} = {8C720480-750C-44C1-945B-961599088853}
- {8C720480-750C-44C1-945B-961599088853} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
- {2093A913-AB5F-4597-839E-A472E25D37D8} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
{AD4DB805-D932-4C5F-9559-B4704340F8CA} = {2093A913-AB5F-4597-839E-A472E25D37D8}
{EED241F9-4900-4FB0-91FD-432A5F40983D} = {2093A913-AB5F-4597-839E-A472E25D37D8}
{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A} = {2093A913-AB5F-4597-839E-A472E25D37D8}
{2031A605-DB91-4998-94DB-8012C590152B} = {2093A913-AB5F-4597-839E-A472E25D37D8}
+ {6BDBDD17-3529-4A03-8DF1-25BEF8577E9B} = {2093A913-AB5F-4597-839E-A472E25D37D8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF807CB9-3F57-4CF4-B501-26F9D4BB417C}
diff --git a/README.md b/README.md
index 596c2f4..6588949 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# ExtCore 4.1.0
+# ExtCore 9.0.0
[](https://gitter.im/ExtCore/ExtCore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -7,17 +7,16 @@
## Introduction
ExtCore is free, open source and cross-platform framework for creating modular and extendable web applications
-based on ASP.NET Core. It is built using the best and the most modern tools and languages (Visual Studio 2017, C#
+based on ASP.NET Core. It is built using the best and the most modern tools and languages (Visual Studio 2022, C#
etc). Join our team!
ExtCore allows you to build your web applications from the different independent reusable modules or extensions.
Each of these modules or extensions may consist of one or more ASP.NET Core projects and each of these projects
may include everything you want as any other ASP.NET Core project. You don’t need to perform any additional
actions to make it all work: any ASP.NET Core project can be used as an ExtCore-based web application extension
-by default. Controllers, view components, views (added as resources and/or precompiled), static content (added as
-resources) are resolved automatically. These projects may be then added to the web application in two ways: as
-direct dependencies (as source code or NuGet packages) or by copying compiled DLLs to the Extensions folder.
-ExtCore supports both of these options out of the box and at the same time.
+by default. Controllers, view components, precompiled views, static content (added as resources) are resolved automatically.
+These projects may be then added to the web application in two ways: as direct dependencies (as source code or NuGet packages)
+or by copying compiled DLLs to the Extensions folder. ExtCore supports both of these options out of the box and at the same time.
Furthermore, any project of the ExtCore-based web application is able to discover the types that are defined
inside all the projects (optionally using the predicates for assemblies filtering) and to get the implementations
@@ -72,8 +71,7 @@ Currently it supports MySQL, PostgreSql, SQLite, and SQL Server, but it is very
#### ExtCore.Mvc
By default, ExtCore web applications are not MVC ones. MVC support is provided for them by ExtCore.Mvc extension.
-This extension initializes MVC, makes it possible to use controllers, view components, views (added as resources
-and/or precompiled), static content (added as resources) from other extensions etc.
+This extension initializes MVC, makes it possible to use controllers, view components, precompiled views, static content (added as resources) from other extensions etc.
#### ExtCore.Events
@@ -95,21 +93,21 @@ in order to execute some code inside the ConfigureServices and Configure methods
Please take a look at our samples on GitHub:
-* [Full-featured ExtCore 4.0.0 framework sample web application](https://github.com/ExtCore/ExtCore-Sample);
-* [ExtCore framework 4.0.0 sample simplest web application](https://github.com/ExtCore/ExtCore-Sample-Simplest);
-* [ExtCore framework 4.0.0 sample MVC web application](https://github.com/ExtCore/ExtCore-Sample-Mvc);
-* [ExtCore framework 4.0.0 sample web application that uses file storage](https://github.com/ExtCore/ExtCore-Sample-FileStorage);
-* [ExtCore framework 4.0.0 sample web application that uses a database](https://github.com/ExtCore/ExtCore-Sample-Data);
-* [ExtCore framework 4.0.0 sample web application that uses Identity](https://github.com/ExtCore/ExtCore-Sample-Identity);
-* [ExtCore framework 4.0.0 sample web application with modular UI](https://github.com/ExtCore/ExtCore-Sample-Modular-Ui);
-* [ExtCore framework 4.0.0 advanced sample web application with modular UI](https://github.com/ExtCore/ExtCore-Sample-Modular-Ui-Adv);
-* [ExtCore framework 4.0.0 advanced sample accounting web application](https://github.com/ExtCore/ExtCore-Sample-Accounting);
-* [ExtCore framework 4.0.0 sample web application that registers a service inside the extension](https://github.com/ExtCore/ExtCore-Sample-Service);
-* [ExtCore framework 4.0.0 sample web application that uses the events](https://github.com/ExtCore/ExtCore-Sample-Events);
-* [ExtCore framework 4.0.0 sample API web application](https://github.com/ExtCore/ExtCore-Sample-Api).
-
-You can also download our [ready to use full-featured sample](http://extcore.net/files/ExtCore-Sample-4.0.0.zip).
-It contains everything you need to run ExtCore-based web application from Visual Studio 2017, including SQLite
+* [Full-featured ExtCore 9.0.0 framework sample web application](https://github.com/ExtCore/ExtCore-Sample);
+* [ExtCore framework 9.0.0 sample simplest web application](https://github.com/ExtCore/ExtCore-Sample-Simplest);
+* [ExtCore framework 9.0.0 sample MVC web application](https://github.com/ExtCore/ExtCore-Sample-Mvc);
+* [ExtCore framework 9.0.0 sample web application that uses file storage](https://github.com/ExtCore/ExtCore-Sample-FileStorage);
+* [ExtCore framework 9.0.0 sample web application that uses a database](https://github.com/ExtCore/ExtCore-Sample-Data);
+* [ExtCore framework 9.0.0 sample web application that uses Identity](https://github.com/ExtCore/ExtCore-Sample-Identity);
+* [ExtCore framework 9.0.0 sample web application with modular UI](https://github.com/ExtCore/ExtCore-Sample-Modular-Ui);
+* [ExtCore framework 9.0.0 advanced sample web application with modular UI](https://github.com/ExtCore/ExtCore-Sample-Modular-Ui-Adv);
+* [ExtCore framework 9.0.0 advanced sample accounting web application](https://github.com/ExtCore/ExtCore-Sample-Accounting);
+* [ExtCore framework 9.0.0 sample web application that registers a service inside the extension](https://github.com/ExtCore/ExtCore-Sample-Service);
+* [ExtCore framework 9.0.0 sample web application that uses the events](https://github.com/ExtCore/ExtCore-Sample-Events);
+* [ExtCore framework 9.0.0 sample API web application](https://github.com/ExtCore/ExtCore-Sample-Api).
+
+You can also download our [ready to use full-featured sample](http://extcore.net/files/ExtCore-Sample-9.0.0.zip).
+It contains everything you need to run ExtCore-based web application from Visual Studio 2022, including SQLite
database with the test data.
### Tutorials
@@ -120,7 +118,7 @@ to help you start developing your ExtCore-based web applications.
### Real Projects
Please take a look at [Platformus](https://github.com/Platformus/Platformus) on GitHub. It is CMS
-built on ExtCore framework with more than 10 extensions and 80 projects.
+built on ExtCore framework with 3 extensions and 25 projects.
## Development and Debug
diff --git a/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj b/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj
index dc718b6..186297d 100644
--- a/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj
+++ b/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj
@@ -1,15 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data extension component. Based on the ExtCore framework.
- 4.1.0
netstandard2.0
ExtCore.Data.Abstractions
ExtCore.Data.Abstractions
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
diff --git a/src/ExtCore.Data.Abstractions/IRepository.cs b/src/ExtCore.Data.Abstractions/IRepository.cs
index aa65ad8..afee570 100644
--- a/src/ExtCore.Data.Abstractions/IRepository.cs
+++ b/src/ExtCore.Data.Abstractions/IRepository.cs
@@ -1,17 +1,16 @@
// Copyright © 2015 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.Data.Abstractions
+namespace ExtCore.Data.Abstractions;
+
+///
+/// Describes a repository for working with the underlying storage context.
+///
+public interface IRepository
{
///
- /// Describes a repository for working with the underlying storage context.
+ /// Sets the storage context to work with.
///
- public interface IRepository
- {
- ///
- /// Sets the storage context to work with.
- ///
- /// The storage context to set.
- void SetStorageContext(IStorageContext storageContext);
- }
+ /// The storage context to set.
+ void SetStorageContext(IStorageContext storageContext);
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Abstractions/IStorage.cs b/src/ExtCore.Data.Abstractions/IStorage.cs
index a5bd713..778382e 100644
--- a/src/ExtCore.Data.Abstractions/IStorage.cs
+++ b/src/ExtCore.Data.Abstractions/IStorage.cs
@@ -3,35 +3,34 @@
using System.Threading.Tasks;
-namespace ExtCore.Data.Abstractions
+namespace ExtCore.Data.Abstractions;
+
+///
+/// Describes a storage that is implementation of the Unit of Work design pattern with the mechanism
+/// of getting the repositories to work with the underlying storage context and committing the changes
+/// made by all the repositories.
+///
+public interface IStorage
{
///
- /// Describes a storage that is implementation of the Unit of Work design pattern with the mechanism
- /// of getting the repositories to work with the underlying storage context and committing the changes
- /// made by all the repositories.
+ /// Gets the underlying storage context used by this storage.
///
- public interface IStorage
- {
- ///
- /// Gets the underlying storage context used by this storage.
- ///
- IStorageContext StorageContext { get; }
+ IStorageContext StorageContext { get; }
- ///
- /// Gets a repository of the given type.
- ///
- /// The type parameter to find implementation of.
- ///
- T GetRepository() where T: IRepository;
+ ///
+ /// Gets a repository of the given type.
+ ///
+ /// The type parameter to find implementation of.
+ ///
+ T GetRepository() where T: IRepository;
- ///
- /// Commits the changes made by all the repositories.
- ///
- void Save();
+ ///
+ /// Commits the changes made by all the repositories.
+ ///
+ int Save();
- ///
- /// Asynchronously commits the changes made by all the repositories.
- ///
- Task SaveAsync();
- }
+ ///
+ /// Asynchronously commits the changes made by all the repositories.
+ ///
+ Task SaveAsync();
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Abstractions/IStorageContext.cs b/src/ExtCore.Data.Abstractions/IStorageContext.cs
index b9aa6f2..89055ad 100644
--- a/src/ExtCore.Data.Abstractions/IStorageContext.cs
+++ b/src/ExtCore.Data.Abstractions/IStorageContext.cs
@@ -1,13 +1,12 @@
// Copyright © 2015 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.Data.Abstractions
+namespace ExtCore.Data.Abstractions;
+
+///
+/// Describes a storage context that must be shared among all the repositories. Storage context
+/// represents concrete storage (for example, SQLite database).
+///
+public interface IStorageContext
{
- ///
- /// Describes a storage context that must be shared among all the repositories. Storage context
- /// represents concrete storage (for example, SQLite database).
- ///
- public interface IStorageContext
- {
- }
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Abstractions/icon.png b/src/ExtCore.Data.Abstractions/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Abstractions/icon.png differ
diff --git a/src/ExtCore.Data.Dapper.MySql/ExtCore.Data.Dapper.MySql.csproj b/src/ExtCore.Data.Dapper.MySql/ExtCore.Data.Dapper.MySql.csproj
index b92a3ad..874a62b 100644
--- a/src/ExtCore.Data.Dapper.MySql/ExtCore.Data.Dapper.MySql.csproj
+++ b/src/ExtCore.Data.Dapper.MySql/ExtCore.Data.Dapper.MySql.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.Dapper.MySql
ExtCore.Data.Dapper.MySql
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.Dapper.MySql/StorageContext.cs b/src/ExtCore.Data.Dapper.MySql/StorageContext.cs
index c02edcd..9ede0bb 100644
--- a/src/ExtCore.Data.Dapper.MySql/StorageContext.cs
+++ b/src/ExtCore.Data.Dapper.MySql/StorageContext.cs
@@ -3,21 +3,20 @@
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.Dapper.MySql
+namespace ExtCore.Data.Dapper.MySql;
+
+///
+/// Implements the IStorageContext interface and represents MySQL database
+/// with the Dapper as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents MySQL database
- /// with the Dapper as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
+ /// The options that are used to connect to the MySQL database.
+ public StorageContext(IOptions options)
+ : base(options)
{
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the MySQL database.
- public StorageContext(IOptions options)
- : base(options)
- {
- }
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper.MySql/icon.png b/src/ExtCore.Data.Dapper.MySql/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Dapper.MySql/icon.png differ
diff --git a/src/ExtCore.Data.Dapper.PostgreSql/ExtCore.Data.Dapper.PostgreSql.csproj b/src/ExtCore.Data.Dapper.PostgreSql/ExtCore.Data.Dapper.PostgreSql.csproj
index f2d0121..1796e32 100644
--- a/src/ExtCore.Data.Dapper.PostgreSql/ExtCore.Data.Dapper.PostgreSql.csproj
+++ b/src/ExtCore.Data.Dapper.PostgreSql/ExtCore.Data.Dapper.PostgreSql.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.Dapper.PostgreSql
ExtCore.Data.Dapper.PostgreSql
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.Dapper.PostgreSql/StorageContext.cs b/src/ExtCore.Data.Dapper.PostgreSql/StorageContext.cs
index 64bb69e..0764bca 100644
--- a/src/ExtCore.Data.Dapper.PostgreSql/StorageContext.cs
+++ b/src/ExtCore.Data.Dapper.PostgreSql/StorageContext.cs
@@ -3,21 +3,20 @@
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.Dapper.PostgreSql
+namespace ExtCore.Data.Dapper.PostgreSql;
+
+///
+/// Implements the IStorageContext interface and represents PostgreSQL database
+/// with the Dapper as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents PostgreSQL database
- /// with the Dapper as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
+ /// The options that are used to connect to the PostgreSQL database.
+ public StorageContext(IOptions options)
+ : base(options)
{
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the PostgreSQL database.
- public StorageContext(IOptions options)
- : base(options)
- {
- }
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper.PostgreSql/icon.png b/src/ExtCore.Data.Dapper.PostgreSql/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Dapper.PostgreSql/icon.png differ
diff --git a/src/ExtCore.Data.Dapper.SqlServer/ExtCore.Data.Dapper.SqlServer.csproj b/src/ExtCore.Data.Dapper.SqlServer/ExtCore.Data.Dapper.SqlServer.csproj
index a9b3e4e..87694c6 100644
--- a/src/ExtCore.Data.Dapper.SqlServer/ExtCore.Data.Dapper.SqlServer.csproj
+++ b/src/ExtCore.Data.Dapper.SqlServer/ExtCore.Data.Dapper.SqlServer.csproj
@@ -1,15 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.Dapper.SqlServer
ExtCore.Data.Dapper.SqlServer
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
diff --git a/src/ExtCore.Data.Dapper.SqlServer/StorageContext.cs b/src/ExtCore.Data.Dapper.SqlServer/StorageContext.cs
index ef7d86f..afcafc3 100644
--- a/src/ExtCore.Data.Dapper.SqlServer/StorageContext.cs
+++ b/src/ExtCore.Data.Dapper.SqlServer/StorageContext.cs
@@ -3,21 +3,20 @@
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.Dapper.SqlServer
+namespace ExtCore.Data.Dapper.SqlServer;
+
+///
+/// Implements the IStorageContext interface and represents SQL Server database
+/// with the Dapper as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents SQL Server database
- /// with the Dapper as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
+ /// The options that are used to connect to the SQL Server database.
+ public StorageContext(IOptions options)
+ : base(options)
{
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the SQL Server database.
- public StorageContext(IOptions options)
- : base(options)
- {
- }
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper.SqlServer/icon.png b/src/ExtCore.Data.Dapper.SqlServer/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Dapper.SqlServer/icon.png differ
diff --git a/src/ExtCore.Data.Dapper.Sqlite/ExtCore.Data.Dapper.Sqlite.csproj b/src/ExtCore.Data.Dapper.Sqlite/ExtCore.Data.Dapper.Sqlite.csproj
index 1fcec00..bb9ba4b 100644
--- a/src/ExtCore.Data.Dapper.Sqlite/ExtCore.Data.Dapper.Sqlite.csproj
+++ b/src/ExtCore.Data.Dapper.Sqlite/ExtCore.Data.Dapper.Sqlite.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.Dapper.Sqlite
ExtCore.Data.Dapper.Sqlite
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.Dapper.Sqlite/StorageContext.cs b/src/ExtCore.Data.Dapper.Sqlite/StorageContext.cs
index 2ea1293..e981d95 100644
--- a/src/ExtCore.Data.Dapper.Sqlite/StorageContext.cs
+++ b/src/ExtCore.Data.Dapper.Sqlite/StorageContext.cs
@@ -3,21 +3,20 @@
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.Dapper.Sqlite
+namespace ExtCore.Data.Dapper.Sqlite;
+
+///
+/// Implements the IStorageContext interface and represents SQLite database
+/// with the Dapper as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents SQLite database
- /// with the Dapper as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
+ /// The options that are used to connect to the SQLite database.
+ public StorageContext(IOptions options)
+ : base(options)
{
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the SQLite database.
- public StorageContext(IOptions options)
- : base(options)
- {
- }
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper.Sqlite/icon.png b/src/ExtCore.Data.Dapper.Sqlite/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Dapper.Sqlite/icon.png differ
diff --git a/src/ExtCore.Data.Dapper/Actions/AddStorageContextAction.cs b/src/ExtCore.Data.Dapper/Actions/AddStorageContextAction.cs
index 26b83b2..827df3f 100644
--- a/src/ExtCore.Data.Dapper/Actions/AddStorageContextAction.cs
+++ b/src/ExtCore.Data.Dapper/Actions/AddStorageContextAction.cs
@@ -10,41 +10,40 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-namespace ExtCore.Data.Dapper.Actions
+namespace ExtCore.Data.Dapper.Actions;
+
+///
+/// Implements the IConfigureServicesAction interface and
+/// registers found implementation of the IStorageContext interface inside the DI.
+///
+public class AddStorageContextAction : IConfigureServicesAction
{
///
- /// Implements the IConfigureServicesAction interface and
- /// registers found implementation of the IStorageContext interface inside the DI.
+ /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
+ ///
+ public int Priority => 1000;
+
+ ///
+ /// Registers found implementation of the IStorageContext interface inside the DI.
///
- public class AddStorageContextAction : IConfigureServicesAction
+ ///
+ /// Will be provided by the ExtCore and might be used to register any service inside the DI.
+ ///
+ ///
+ /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
+ ///
+ public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
{
- ///
- /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
- ///
- public int Priority => 1000;
+ Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
- ///
- /// Registers found implementation of the IStorageContext interface inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to register any service inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
- ///
- public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
+ if (type == null)
{
- Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
+ ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.Data.Dapper");
- if (type == null)
- {
- ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.Data.Dapper");
-
- logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorageContext not found");
- return;
- }
-
- services.AddScoped(typeof(IStorageContext), type);
+ logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorageContext not found");
+ return;
}
+
+ services.AddScoped(typeof(IStorageContext), type);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper/ExtCore.Data.Dapper.csproj b/src/ExtCore.Data.Dapper/ExtCore.Data.Dapper.csproj
index b717b11..367721d 100644
--- a/src/ExtCore.Data.Dapper/ExtCore.Data.Dapper.csproj
+++ b/src/ExtCore.Data.Dapper/ExtCore.Data.Dapper.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.Dapper
ExtCore.Data.Dapper
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.Dapper/Extension.cs b/src/ExtCore.Data.Dapper/Extension.cs
index 10f3ad0..9de1801 100644
--- a/src/ExtCore.Data.Dapper/Extension.cs
+++ b/src/ExtCore.Data.Dapper/Extension.cs
@@ -3,32 +3,31 @@
using ExtCore.Infrastructure;
-namespace ExtCore.Data.Dapper
+namespace ExtCore.Data.Dapper;
+
+///
+/// Overrides the ExtensionBase class and provides the
+/// ExtCore.Data.Dapper extension information.
+///
+public class Extension : ExtensionBase
{
///
- /// Overrides the ExtensionBase class and provides the
- /// ExtCore.Data.Dapper extension information.
+ /// Gets the name of the extension.
///
- public class Extension : ExtensionBase
- {
- ///
- /// Gets the name of the extension.
- ///
- public override string Name => "ExtCore.Data.Dapper";
+ public override string Name => "ExtCore.Data.Dapper";
- ///
- /// Gets the URL of the extension.
- ///
- public override string Url => "http://extcore.net/";
+ ///
+ /// Gets the URL of the extension.
+ ///
+ public override string Url => "https://extcore.net/";
- ///
- /// Gets the version of the extension.
- ///
- public override string Version => "4.1.0";
+ ///
+ /// Gets the version of the extension.
+ ///
+ public override string Version => "8.1.0";
- ///
- /// Gets the authors of the extension (separated by commas).
- ///
- public override string Authors => "Dmitry Sikorsky";
- }
+ ///
+ /// Gets the authors of the extension (separated by commas).
+ ///
+ public override string Authors => "Dmitry Sikorsky";
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper/RepositoryBase.cs b/src/ExtCore.Data.Dapper/RepositoryBase.cs
index ff57599..f94302b 100644
--- a/src/ExtCore.Data.Dapper/RepositoryBase.cs
+++ b/src/ExtCore.Data.Dapper/RepositoryBase.cs
@@ -4,25 +4,24 @@
using ExtCore.Data.Abstractions;
using ExtCore.Data.Entities.Abstractions;
-namespace ExtCore.Data.Dapper
+namespace ExtCore.Data.Dapper;
+
+///
+/// Implements the IRepository interface and represents default repository behavior.
+///
+/// The entity type this repository operates.
+public abstract class RepositoryBase : IRepository where TEntity : class, IEntity
{
+ protected IStorageContext storageContext;
+ protected string connectionString;
+
///
- /// Implements the IRepository interface and represents default repository behavior.
+ /// Sets the Dapper storage context that represents the physical storage to work with.
///
- /// The entity type this repository operates.
- public abstract class RepositoryBase : IRepository where TEntity : class, IEntity
+ /// The Dapper storage context to set.
+ public void SetStorageContext(IStorageContext storageContext)
{
- protected IStorageContext storageContext;
- protected string connectionString;
-
- ///
- /// Sets the Dapper storage context that represents the physical storage to work with.
- ///
- /// The Dapper storage context to set.
- public void SetStorageContext(IStorageContext storageContext)
- {
- this.storageContext = storageContext;
- this.connectionString = (storageContext as StorageContextBase).ConnectionString;
- }
+ this.storageContext = storageContext;
+ this.connectionString = (storageContext as StorageContextBase).ConnectionString;
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper/Storage.cs b/src/ExtCore.Data.Dapper/Storage.cs
index 37fbab3..2d5a3a2 100644
--- a/src/ExtCore.Data.Dapper/Storage.cs
+++ b/src/ExtCore.Data.Dapper/Storage.cs
@@ -5,52 +5,53 @@
using ExtCore.Data.Abstractions;
using ExtCore.Infrastructure;
-namespace ExtCore.Data.Dapper
+namespace ExtCore.Data.Dapper;
+
+///
+/// Implements the IStorage interface and represents implementation of the
+/// Unit of Work design pattern with the mechanism of getting the repositories to work with the underlying
+/// Dapper storage context and committing the changes made by all the repositories.
+///
+public class Storage : IStorage
{
///
- /// Implements the IStorage interface and represents implementation of the
- /// Unit of Work design pattern with the mechanism of getting the repositories to work with the underlying
- /// Dapper storage context and committing the changes made by all the repositories.
+ /// Gets the Dapper storage context.
///
- public class Storage : IStorage
+ public IStorageContext StorageContext { get; private set; }
+
+ public Storage(IStorageContext storageContext)
+ {
+ this.StorageContext = storageContext;
+ }
+
+ ///
+ /// Gets a repository of the given type.
+ ///
+ /// The type parameter to find implementation of.
+ ///
+ public TRepository GetRepository() where TRepository : IRepository
+ {
+ TRepository repository = ExtensionManager.GetInstance();
+
+ if (repository != null)
+ repository.SetStorageContext(this.StorageContext);
+
+ return repository;
+ }
+
+ ///
+ /// Commits the changes made by all the repositories.
+ ///
+ public int Save()
+ {
+ return -1;
+ }
+
+ ///
+ /// Asynchronously commits the changes made by all the repositories.
+ ///
+ public async Task SaveAsync()
{
- ///
- /// Gets the Dapper storage context.
- ///
- public IStorageContext StorageContext { get; private set; }
-
- public Storage(IStorageContext storageContext)
- {
- this.StorageContext = storageContext;
- }
-
- ///
- /// Gets a repository of the given type.
- ///
- /// The type parameter to find implementation of.
- ///
- public TRepository GetRepository() where TRepository : IRepository
- {
- TRepository repository = ExtensionManager.GetInstance();
-
- if (repository != null)
- repository.SetStorageContext(this.StorageContext);
-
- return repository;
- }
-
- ///
- /// Commits the changes made by all the repositories.
- ///
- public void Save()
- {
- }
-
- ///
- /// Asynchronously commits the changes made by all the repositories.
- ///
- public async Task SaveAsync()
- {
- }
+ return -1;
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper/StorageContextBase.cs b/src/ExtCore.Data.Dapper/StorageContextBase.cs
index d8677bc..e8d7872 100644
--- a/src/ExtCore.Data.Dapper/StorageContextBase.cs
+++ b/src/ExtCore.Data.Dapper/StorageContextBase.cs
@@ -4,26 +4,25 @@
using ExtCore.Data.Abstractions;
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.Dapper
+namespace ExtCore.Data.Dapper;
+
+///
+/// Implements the IStorageContext interface and represents the physical storage
+/// with the Dapper Core as the ORM.
+///
+public abstract class StorageContextBase : IStorageContext
{
///
- /// Implements the IStorageContext interface and represents the physical storage
- /// with the Dapper Core as the ORM.
+ /// The connection string that is used to connect to the physical storage.
///
- public abstract class StorageContextBase : IStorageContext
- {
- ///
- /// The connection string that is used to connect to the physical storage.
- ///
- public string ConnectionString { get; private set; }
+ public string ConnectionString { get; private set; }
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The connection string that is used to connect to the physical storage.
- public StorageContextBase(IOptions options)
- {
- this.ConnectionString = options.Value.ConnectionString;
- }
+ ///
+ /// Initializes a new instance of the StorageContext class.
+ ///
+ /// The connection string that is used to connect to the physical storage.
+ public StorageContextBase(IOptions options)
+ {
+ this.ConnectionString = options.Value.ConnectionString;
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper/StorageContextOptions.cs b/src/ExtCore.Data.Dapper/StorageContextOptions.cs
index e22b924..5691a6b 100644
--- a/src/ExtCore.Data.Dapper/StorageContextOptions.cs
+++ b/src/ExtCore.Data.Dapper/StorageContextOptions.cs
@@ -1,16 +1,15 @@
// Copyright © 2017 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.Data.Dapper
+namespace ExtCore.Data.Dapper;
+
+///
+/// Represents Dapper storage context options.
+///
+public class StorageContextOptions
{
///
- /// Represents Dapper storage context options.
+ /// The connection string that is used to connect to the physical storage.
///
- public class StorageContextOptions
- {
- ///
- /// The connection string that is used to connect to the physical storage.
- ///
- public string ConnectionString { get; set; }
- }
+ public string ConnectionString { get; set; }
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Dapper/icon.png b/src/ExtCore.Data.Dapper/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Dapper/icon.png differ
diff --git a/src/ExtCore.Data.Entities.Abstractions/ExtCore.Data.Entities.Abstractions.csproj b/src/ExtCore.Data.Entities.Abstractions/ExtCore.Data.Entities.Abstractions.csproj
index f431231..023a3dd 100644
--- a/src/ExtCore.Data.Entities.Abstractions/ExtCore.Data.Entities.Abstractions.csproj
+++ b/src/ExtCore.Data.Entities.Abstractions/ExtCore.Data.Entities.Abstractions.csproj
@@ -1,15 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data extension component. Based on the ExtCore framework.
- 4.1.0
netstandard2.0
ExtCore.Data.Entities.Abstractions
ExtCore.Data.Entities.Abstractions
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
diff --git a/src/ExtCore.Data.Entities.Abstractions/IEntity.cs b/src/ExtCore.Data.Entities.Abstractions/IEntity.cs
index b6c8236..2208af2 100644
--- a/src/ExtCore.Data.Entities.Abstractions/IEntity.cs
+++ b/src/ExtCore.Data.Entities.Abstractions/IEntity.cs
@@ -1,12 +1,11 @@
// Copyright © 2015 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.Data.Entities.Abstractions
+namespace ExtCore.Data.Entities.Abstractions;
+
+///
+/// Describes an entity.
+///
+public interface IEntity
{
- ///
- /// Describes an entity.
- ///
- public interface IEntity
- {
- }
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.Entities.Abstractions/icon.png b/src/ExtCore.Data.Entities.Abstractions/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.Entities.Abstractions/icon.png differ
diff --git a/src/ExtCore.Data.EntityFramework.MySql/ExtCore.Data.EntityFramework.MySql.csproj b/src/ExtCore.Data.EntityFramework.MySql/ExtCore.Data.EntityFramework.MySql.csproj
index bd4320e..41554ce 100644
--- a/src/ExtCore.Data.EntityFramework.MySql/ExtCore.Data.EntityFramework.MySql.csproj
+++ b/src/ExtCore.Data.EntityFramework.MySql/ExtCore.Data.EntityFramework.MySql.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.EntityFramework.MySql
ExtCore.Data.EntityFramework.MySql
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.EntityFramework.MySql/StorageContext.cs b/src/ExtCore.Data.EntityFramework.MySql/StorageContext.cs
index 38fba6e..3daec68 100644
--- a/src/ExtCore.Data.EntityFramework.MySql/StorageContext.cs
+++ b/src/ExtCore.Data.EntityFramework.MySql/StorageContext.cs
@@ -4,34 +4,33 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.EntityFramework.MySql
+namespace ExtCore.Data.EntityFramework.MySql;
+
+///
+/// Implements the IStorageContext interface and represents MySQL database
+/// with the Entity Framework Core as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents MySQL database
- /// with the Entity Framework Core as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
- {
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the MySQL database.
- public StorageContext(IOptions options) : base(options) { }
+ /// The options that are used to connect to the MySQL database.
+ public StorageContext(IOptions options) : base(options) { }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- base.OnConfiguring(optionsBuilder);
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ base.OnConfiguring(optionsBuilder);
- if (string.IsNullOrEmpty(this.MigrationsAssembly))
- optionsBuilder.UseMySQL(this.ConnectionString);
+ if (string.IsNullOrEmpty(this.MigrationsAssembly))
+ optionsBuilder.UseMySQL(this.ConnectionString);
- else optionsBuilder.UseMySQL(
- this.ConnectionString,
- options =>
- {
- options.MigrationsAssembly(this.MigrationsAssembly);
- }
- );
- }
+ else optionsBuilder.UseMySQL(
+ this.ConnectionString,
+ options =>
+ {
+ options.MigrationsAssembly(this.MigrationsAssembly);
+ }
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework.MySql/icon.png b/src/ExtCore.Data.EntityFramework.MySql/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.EntityFramework.MySql/icon.png differ
diff --git a/src/ExtCore.Data.EntityFramework.PostgreSql/ExtCore.Data.EntityFramework.PostgreSql.csproj b/src/ExtCore.Data.EntityFramework.PostgreSql/ExtCore.Data.EntityFramework.PostgreSql.csproj
index 8c0ddf7..a0f4bbf 100644
--- a/src/ExtCore.Data.EntityFramework.PostgreSql/ExtCore.Data.EntityFramework.PostgreSql.csproj
+++ b/src/ExtCore.Data.EntityFramework.PostgreSql/ExtCore.Data.EntityFramework.PostgreSql.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.EntityFramework.PostgreSql
ExtCore.Data.EntityFramework.PostgreSql
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.EntityFramework.PostgreSql/StorageContext.cs b/src/ExtCore.Data.EntityFramework.PostgreSql/StorageContext.cs
index 9656f21..099d407 100644
--- a/src/ExtCore.Data.EntityFramework.PostgreSql/StorageContext.cs
+++ b/src/ExtCore.Data.EntityFramework.PostgreSql/StorageContext.cs
@@ -4,34 +4,33 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.EntityFramework.PostgreSql
+namespace ExtCore.Data.EntityFramework.PostgreSql;
+
+///
+/// Implements the IStorageContext interface and represents PostgreSQL database
+/// with the Entity Framework Core as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents PostgreSQL database
- /// with the Entity Framework Core as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
- {
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the PostgreSQL database.
- public StorageContext(IOptions options) : base(options) { }
+ /// The options that are used to connect to the PostgreSQL database.
+ public StorageContext(IOptions options) : base(options) { }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- base.OnConfiguring(optionsBuilder);
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ base.OnConfiguring(optionsBuilder);
- if (string.IsNullOrEmpty(this.MigrationsAssembly))
- optionsBuilder.UseNpgsql(this.ConnectionString);
+ if (string.IsNullOrEmpty(this.MigrationsAssembly))
+ optionsBuilder.UseNpgsql(this.ConnectionString);
- else optionsBuilder.UseNpgsql(
- this.ConnectionString,
- options =>
- {
- options.MigrationsAssembly(this.MigrationsAssembly);
- }
- );
- }
+ else optionsBuilder.UseNpgsql(
+ this.ConnectionString,
+ options =>
+ {
+ options.MigrationsAssembly(this.MigrationsAssembly);
+ }
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework.PostgreSql/icon.png b/src/ExtCore.Data.EntityFramework.PostgreSql/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.EntityFramework.PostgreSql/icon.png differ
diff --git a/src/ExtCore.Data.EntityFramework.SqlServer/ExtCore.Data.EntityFramework.SqlServer.csproj b/src/ExtCore.Data.EntityFramework.SqlServer/ExtCore.Data.EntityFramework.SqlServer.csproj
index f0875ca..b9a464a 100644
--- a/src/ExtCore.Data.EntityFramework.SqlServer/ExtCore.Data.EntityFramework.SqlServer.csproj
+++ b/src/ExtCore.Data.EntityFramework.SqlServer/ExtCore.Data.EntityFramework.SqlServer.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.EntityFramework.SqlServer
ExtCore.Data.EntityFramework.SqlServer
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.EntityFramework.SqlServer/StorageContext.cs b/src/ExtCore.Data.EntityFramework.SqlServer/StorageContext.cs
index 0852b03..1665173 100644
--- a/src/ExtCore.Data.EntityFramework.SqlServer/StorageContext.cs
+++ b/src/ExtCore.Data.EntityFramework.SqlServer/StorageContext.cs
@@ -4,34 +4,33 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.EntityFramework.SqlServer
+namespace ExtCore.Data.EntityFramework.SqlServer;
+
+///
+/// Implements the IStorageContext interface and represents SQL Server database
+/// with the Entity Framework Core as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents SQL Server database
- /// with the Entity Framework Core as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
- {
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the SQL Server database.
- public StorageContext(IOptions options) : base(options) { }
+ /// The options that are used to connect to the SQL Server database.
+ public StorageContext(IOptions options) : base(options) { }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- base.OnConfiguring(optionsBuilder);
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ base.OnConfiguring(optionsBuilder);
- if (string.IsNullOrEmpty(this.MigrationsAssembly))
- optionsBuilder.UseSqlServer(this.ConnectionString);
+ if (string.IsNullOrEmpty(this.MigrationsAssembly))
+ optionsBuilder.UseSqlServer(this.ConnectionString);
- else optionsBuilder.UseSqlServer(
- this.ConnectionString,
- options =>
- {
- options.MigrationsAssembly(this.MigrationsAssembly);
- }
- );
- }
+ else optionsBuilder.UseSqlServer(
+ this.ConnectionString,
+ options =>
+ {
+ options.MigrationsAssembly(this.MigrationsAssembly);
+ }
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework.SqlServer/icon.png b/src/ExtCore.Data.EntityFramework.SqlServer/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.EntityFramework.SqlServer/icon.png differ
diff --git a/src/ExtCore.Data.EntityFramework.Sqlite/ExtCore.Data.EntityFramework.Sqlite.csproj b/src/ExtCore.Data.EntityFramework.Sqlite/ExtCore.Data.EntityFramework.Sqlite.csproj
index e7f2c11..ec6bad0 100644
--- a/src/ExtCore.Data.EntityFramework.Sqlite/ExtCore.Data.EntityFramework.Sqlite.csproj
+++ b/src/ExtCore.Data.EntityFramework.Sqlite/ExtCore.Data.EntityFramework.Sqlite.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.EntityFramework.Sqlite
ExtCore.Data.EntityFramework.Sqlite
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.EntityFramework.Sqlite/StorageContext.cs b/src/ExtCore.Data.EntityFramework.Sqlite/StorageContext.cs
index d288f0d..90ee51a 100644
--- a/src/ExtCore.Data.EntityFramework.Sqlite/StorageContext.cs
+++ b/src/ExtCore.Data.EntityFramework.Sqlite/StorageContext.cs
@@ -4,37 +4,36 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.EntityFramework.Sqlite
+namespace ExtCore.Data.EntityFramework.Sqlite;
+
+///
+/// Implements the IStorageContext interface and represents SQLite database
+/// with the Entity Framework Core as the ORM.
+///
+public class StorageContext : StorageContextBase
{
///
- /// Implements the IStorageContext interface and represents SQLite database
- /// with the Entity Framework Core as the ORM.
+ /// Initializes a new instance of the StorageContext class.
///
- public class StorageContext : StorageContextBase
+ /// The options that are used to connect to the SQLite database.
+ public StorageContext(IOptions options)
+ : base(options)
{
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The options that are used to connect to the SQLite database.
- public StorageContext(IOptions options)
- : base(options)
- {
- }
+ }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- base.OnConfiguring(optionsBuilder);
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ base.OnConfiguring(optionsBuilder);
- if (string.IsNullOrEmpty(this.MigrationsAssembly))
- optionsBuilder.UseSqlite(this.ConnectionString);
+ if (string.IsNullOrEmpty(this.MigrationsAssembly))
+ optionsBuilder.UseSqlite(this.ConnectionString);
- else optionsBuilder.UseSqlite(
- this.ConnectionString,
- options =>
- {
- options.MigrationsAssembly(this.MigrationsAssembly);
- }
- );
- }
+ else optionsBuilder.UseSqlite(
+ this.ConnectionString,
+ options =>
+ {
+ options.MigrationsAssembly(this.MigrationsAssembly);
+ }
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework.Sqlite/icon.png b/src/ExtCore.Data.EntityFramework.Sqlite/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.EntityFramework.Sqlite/icon.png differ
diff --git a/src/ExtCore.Data.EntityFramework/Actions/AddStorageContextAction.cs b/src/ExtCore.Data.EntityFramework/Actions/AddStorageContextAction.cs
index 0c40a3a..045e870 100644
--- a/src/ExtCore.Data.EntityFramework/Actions/AddStorageContextAction.cs
+++ b/src/ExtCore.Data.EntityFramework/Actions/AddStorageContextAction.cs
@@ -10,41 +10,40 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-namespace ExtCore.Data.EntityFramework.Actions
+namespace ExtCore.Data.EntityFramework.Actions;
+
+///
+/// Implements the IConfigureServicesAction interface and
+/// registers found implementation of the IStorageContext interface inside the DI.
+///
+public class AddStorageContextAction : IConfigureServicesAction
{
///
- /// Implements the IConfigureServicesAction interface and
- /// registers found implementation of the IStorageContext interface inside the DI.
+ /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
+ ///
+ public int Priority => 1000;
+
+ ///
+ /// Registers found implementation of the IStorageContext interface inside the DI.
///
- public class AddStorageContextAction : IConfigureServicesAction
+ ///
+ /// Will be provided by the ExtCore and might be used to register any service inside the DI.
+ ///
+ ///
+ /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
+ ///
+ public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
{
- ///
- /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
- ///
- public int Priority => 1000;
+ Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
- ///
- /// Registers found implementation of the IStorageContext interface inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to register any service inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
- ///
- public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
+ if (type == null)
{
- Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
+ ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.Data.EntityFramework");
- if (type == null)
- {
- ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.Data.EntityFramework");
-
- logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorageContext not found");
- return;
- }
-
- services.AddScoped(typeof(IStorageContext), type);
+ logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorageContext not found");
+ return;
}
+
+ services.AddScoped(typeof(IStorageContext), type);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/DesignTimeStorageContextFactoryBase.cs b/src/ExtCore.Data.EntityFramework/DesignTimeStorageContextFactoryBase.cs
index f954a9b..3611e98 100644
--- a/src/ExtCore.Data.EntityFramework/DesignTimeStorageContextFactoryBase.cs
+++ b/src/ExtCore.Data.EntityFramework/DesignTimeStorageContextFactoryBase.cs
@@ -6,41 +6,40 @@
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.DependencyInjection;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Implements the interface and represents the factory for providing
+/// the registered inside the DI storage context service to the Entity Framework Core tools (such as Migrations).
+/// Inherit from this class and call the Initialize method in your web application after the class
+/// is configured in order the Entity Framework Core tools (such as Migrations) to work.
+///
+/// The storage context type this factory creates.
+public abstract class DesignTimeStorageContextFactoryBase : IDesignTimeDbContextFactory where T : StorageContextBase
{
///
- /// Implements the interface and represents the factory for providing
- /// the registered inside the DI storage context service to the Entity Framework Core tools (such as Migrations).
- /// Inherit from this class and call the Initialize method in your web application after the class
- /// is configured in order the Entity Framework Core tools (such as Migrations) to work.
+ /// The storage context service from the DI.
///
- /// The storage context type this factory creates.
- public abstract class DesignTimeStorageContextFactoryBase : IDesignTimeDbContextFactory where T : StorageContextBase
- {
- ///
- /// The storage context service from the DI.
- ///
- public static T StorageContext { get; set; }
+ public static T StorageContext { get; set; }
- ///
- /// Gets the storage context service set by the Initialize method.
- ///
- ///
- /// Storage context service set by the Initialize method.
- public T CreateDbContext(string[] args)
- {
- return DesignTimeStorageContextFactoryBase.StorageContext;
- }
+ ///
+ /// Gets the storage context service set by the Initialize method.
+ ///
+ ///
+ /// Storage context service set by the Initialize method.
+ public T CreateDbContext(string[] args)
+ {
+ return DesignTimeStorageContextFactoryBase.StorageContext;
+ }
- ///
- /// Gets the storage context service from the DI and then sets it to the StorageContext property.
- /// Call this method inside the Startup.ConfigureServices one after the class
- /// is configured.
- ///
- /// The service provider to get the storage context service.
- public static void Initialize(IServiceProvider serviceProvider)
- {
- DesignTimeStorageContextFactoryBase.StorageContext = serviceProvider.GetService() as T;
- }
+ ///
+ /// Gets the storage context service from the DI and then sets it to the StorageContext property.
+ /// Call this method inside the Startup.ConfigureServices one after the class
+ /// is configured.
+ ///
+ /// The service provider to get the storage context service.
+ public static void Initialize(IServiceProvider serviceProvider)
+ {
+ DesignTimeStorageContextFactoryBase.StorageContext = serviceProvider.GetService() as T;
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/ExtCore.Data.EntityFramework.csproj b/src/ExtCore.Data.EntityFramework/ExtCore.Data.EntityFramework.csproj
index 0061dda..40f1857 100644
--- a/src/ExtCore.Data.EntityFramework/ExtCore.Data.EntityFramework.csproj
+++ b/src/ExtCore.Data.EntityFramework/ExtCore.Data.EntityFramework.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data.EntityFramework
ExtCore.Data.EntityFramework
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.Data.EntityFramework/Extension.cs b/src/ExtCore.Data.EntityFramework/Extension.cs
index 888456f..ac2f072 100644
--- a/src/ExtCore.Data.EntityFramework/Extension.cs
+++ b/src/ExtCore.Data.EntityFramework/Extension.cs
@@ -3,32 +3,31 @@
using ExtCore.Infrastructure;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Overrides the ExtensionBase class and provides the
+/// ExtCore.Data.EntityFramework extension information.
+///
+public class Extension : ExtensionBase
{
///
- /// Overrides the ExtensionBase class and provides the
- /// ExtCore.Data.EntityFramework extension information.
+ /// Gets the name of the extension.
///
- public class Extension : ExtensionBase
- {
- ///
- /// Gets the name of the extension.
- ///
- public override string Name => "ExtCore.Data.EntityFramework";
+ public override string Name => "ExtCore.Data.EntityFramework";
- ///
- /// Gets the URL of the extension.
- ///
- public override string Url => "http://extcore.net/";
+ ///
+ /// Gets the URL of the extension.
+ ///
+ public override string Url => "https://extcore.net/";
- ///
- /// Gets the version of the extension.
- ///
- public override string Version => "4.1.0";
+ ///
+ /// Gets the version of the extension.
+ ///
+ public override string Version => "8.1.0";
- ///
- /// Gets the authors of the extension (separated by commas).
- ///
- public override string Authors => "Dmitry Sikorsky";
- }
+ ///
+ /// Gets the authors of the extension (separated by commas).
+ ///
+ public override string Authors => "Dmitry Sikorsky";
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/Extensions/StorageContextExtensions.cs b/src/ExtCore.Data.EntityFramework/Extensions/StorageContextExtensions.cs
index f8d15f5..81acefd 100644
--- a/src/ExtCore.Data.EntityFramework/Extensions/StorageContextExtensions.cs
+++ b/src/ExtCore.Data.EntityFramework/Extensions/StorageContextExtensions.cs
@@ -5,23 +5,22 @@
using ExtCore.Infrastructure;
using Microsoft.EntityFrameworkCore;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Contains the extension methods of the IStorageContext interface.
+///
+public static class StorageContextExtensions
{
///
- /// Contains the extension methods of the IStorageContext interface.
+ /// Registers the entities from all the extensions inside the single Entity Framework storage context
+ /// by finding all the implementations of the IEntityRegistrar interface.
///
- public static class StorageContextExtensions
+ /// The Entity Framework storage context.
+ /// The Entity Framework model builder.
+ public static void RegisterEntities(this IStorageContext storageContext, ModelBuilder modelBuilder)
{
- ///
- /// Registers the entities from all the extensions inside the single Entity Framework storage context
- /// by finding all the implementations of the IEntityRegistrar interface.
- ///
- /// The Entity Framework storage context.
- /// The Entity Framework model builder.
- public static void RegisterEntities(this IStorageContext storageContext, ModelBuilder modelBuilder)
- {
- foreach (IEntityRegistrar entityRegistrar in ExtensionManager.GetInstances())
- entityRegistrar.RegisterEntities(modelBuilder);
- }
+ foreach (IEntityRegistrar entityRegistrar in ExtensionManager.GetInstances())
+ entityRegistrar.RegisterEntities(modelBuilder);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/IEntityRegistrar.cs b/src/ExtCore.Data.EntityFramework/IEntityRegistrar.cs
index abf13dd..f03d4a3 100644
--- a/src/ExtCore.Data.EntityFramework/IEntityRegistrar.cs
+++ b/src/ExtCore.Data.EntityFramework/IEntityRegistrar.cs
@@ -3,17 +3,16 @@
using Microsoft.EntityFrameworkCore;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Describes a mechanism of registering entities inside the Entity Framework storage context.
+///
+public interface IEntityRegistrar
{
///
- /// Describes a mechanism of registering entities inside the Entity Framework storage context.
+ /// Registers entities inside the Entity Framework storage context.
///
- public interface IEntityRegistrar
- {
- ///
- /// Registers entities inside the Entity Framework storage context.
- ///
- /// The Entity Framework model builder.
- void RegisterEntities(ModelBuilder modelbuilder);
- }
+ /// The Entity Framework model builder.
+ void RegisterEntities(ModelBuilder modelbuilder);
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/RepositoryBase.cs b/src/ExtCore.Data.EntityFramework/RepositoryBase.cs
index 1a022c1..40f9ced 100644
--- a/src/ExtCore.Data.EntityFramework/RepositoryBase.cs
+++ b/src/ExtCore.Data.EntityFramework/RepositoryBase.cs
@@ -5,25 +5,24 @@
using ExtCore.Data.Entities.Abstractions;
using Microsoft.EntityFrameworkCore;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Implements the IRepository interface and represents default repository behavior.
+///
+/// The entity type this repository operates.
+public abstract class RepositoryBase : IRepository where TEntity : class, IEntity
{
+ protected DbContext storageContext;
+ protected DbSet dbSet;
+
///
- /// Implements the IRepository interface and represents default repository behavior.
+ /// Sets the Entity Framework storage context that represents the physical storage to work with.
///
- /// The entity type this repository operates.
- public abstract class RepositoryBase : IRepository where TEntity : class, IEntity
+ /// The Entity Framework storage context to set.
+ public void SetStorageContext(IStorageContext storageContext)
{
- protected DbContext storageContext;
- protected DbSet dbSet;
-
- ///
- /// Sets the Entity Framework storage context that represents the physical storage to work with.
- ///
- /// The Entity Framework storage context to set.
- public void SetStorageContext(IStorageContext storageContext)
- {
- this.storageContext = storageContext as DbContext;
- this.dbSet = this.storageContext.Set();
- }
+ this.storageContext = storageContext as DbContext;
+ this.dbSet = this.storageContext.Set();
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/Storage.cs b/src/ExtCore.Data.EntityFramework/Storage.cs
index eedae26..6a7ac93 100644
--- a/src/ExtCore.Data.EntityFramework/Storage.cs
+++ b/src/ExtCore.Data.EntityFramework/Storage.cs
@@ -7,57 +7,56 @@
using ExtCore.Infrastructure;
using Microsoft.EntityFrameworkCore;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Implements the IStorage interface and represents implementation of the
+/// Unit of Work design pattern with the mechanism of getting the repositories to work with the underlying
+/// Entity Framework storage context and committing the changes made by all the repositories.
+///
+public class Storage : IStorage
{
///
- /// Implements the IStorage interface and represents implementation of the
- /// Unit of Work design pattern with the mechanism of getting the repositories to work with the underlying
- /// Entity Framework storage context and committing the changes made by all the repositories.
+ /// Gets the Entity Framework storage context.
///
- public class Storage : IStorage
+ public IStorageContext StorageContext { get; private set; }
+
+ public Storage(IStorageContext storageContext)
+ {
+ if (!(storageContext is DbContext))
+ throw new ArgumentException("The storageContext object must be an instance of the Microsoft.EntityFrameworkCore.DbContext class.");
+
+ this.StorageContext = storageContext;
+ }
+
+ ///
+ /// Gets a repository of the given type.
+ ///
+ /// The type parameter to find implementation of.
+ ///
+ public TRepository GetRepository() where TRepository : IRepository
+ {
+ TRepository repository = ExtensionManager.GetInstance();
+
+ if (repository != null)
+ repository.SetStorageContext(this.StorageContext);
+
+ return repository;
+ }
+
+ ///
+ /// Commits the changes made by all the repositories.
+ ///
+ public int Save()
+ {
+ return (this.StorageContext as DbContext).SaveChanges();
+ }
+
+ ///
+ /// Asynchronously commits the changes made by all the repositories.
+ ///
+ public async Task SaveAsync()
{
- ///
- /// Gets the Entity Framework storage context.
- ///
- public IStorageContext StorageContext { get; private set; }
-
- public Storage(IStorageContext storageContext)
- {
- if (!(storageContext is DbContext))
- throw new ArgumentException("The storageContext object must be an instance of the Microsoft.EntityFrameworkCore.DbContext class.");
-
- this.StorageContext = storageContext;
- }
-
- ///
- /// Gets a repository of the given type.
- ///
- /// The type parameter to find implementation of.
- ///
- public TRepository GetRepository() where TRepository : IRepository
- {
- TRepository repository = ExtensionManager.GetInstance();
-
- if (repository != null)
- repository.SetStorageContext(this.StorageContext);
-
- return repository;
- }
-
- ///
- /// Commits the changes made by all the repositories.
- ///
- public void Save()
- {
- (this.StorageContext as DbContext).SaveChanges();
- }
-
- ///
- /// Asynchronously commits the changes made by all the repositories.
- ///
- public async Task SaveAsync()
- {
- await (this.StorageContext as DbContext).SaveChangesAsync();
- }
+ return await (this.StorageContext as DbContext).SaveChangesAsync();
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/StorageContextBase.cs b/src/ExtCore.Data.EntityFramework/StorageContextBase.cs
index edc47c4..90a5e1d 100644
--- a/src/ExtCore.Data.EntityFramework/StorageContextBase.cs
+++ b/src/ExtCore.Data.EntityFramework/StorageContextBase.cs
@@ -5,38 +5,37 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Implements the IStorageContext interface and represents the physical storage
+/// with the Entity Framework Core as the ORM.
+///
+public abstract class StorageContextBase : DbContext, IStorageContext
{
///
- /// Implements the IStorageContext interface and represents the physical storage
- /// with the Entity Framework Core as the ORM.
+ /// The connection string that is used to connect to the physical storage.
///
- public abstract class StorageContextBase : DbContext, IStorageContext
- {
- ///
- /// The connection string that is used to connect to the physical storage.
- ///
- public string ConnectionString { get; private set; }
+ public string ConnectionString { get; private set; }
- ///
- /// The assembly name where migrations are maintained for this context.
- ///
- public string MigrationsAssembly { get; private set; }
+ ///
+ /// The assembly name where migrations are maintained for this context.
+ ///
+ public string MigrationsAssembly { get; private set; }
- ///
- /// Initializes a new instance of the StorageContext class.
- ///
- /// The connection string that is used to connect to the physical storage.
- public StorageContextBase(IOptions options)
- {
- this.ConnectionString = options.Value.ConnectionString;
- this.MigrationsAssembly = options.Value.MigrationsAssembly;
- }
+ ///
+ /// Initializes a new instance of the StorageContext class.
+ ///
+ /// The connection string that is used to connect to the physical storage.
+ public StorageContextBase(IOptions options)
+ {
+ this.ConnectionString = options.Value.ConnectionString;
+ this.MigrationsAssembly = options.Value.MigrationsAssembly;
+ }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- this.RegisterEntities(modelBuilder);
- }
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+ this.RegisterEntities(modelBuilder);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/StorageContextOptions.cs b/src/ExtCore.Data.EntityFramework/StorageContextOptions.cs
index 3d82d98..cff88ab 100644
--- a/src/ExtCore.Data.EntityFramework/StorageContextOptions.cs
+++ b/src/ExtCore.Data.EntityFramework/StorageContextOptions.cs
@@ -1,21 +1,20 @@
// Copyright © 2017 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.Data.EntityFramework
+namespace ExtCore.Data.EntityFramework;
+
+///
+/// Represents Entity Framework storage context options.
+///
+public class StorageContextOptions
{
///
- /// Represents Entity Framework storage context options.
+ /// The connection string that is used to connect to the physical storage.
///
- public class StorageContextOptions
- {
- ///
- /// The connection string that is used to connect to the physical storage.
- ///
- public string ConnectionString { get; set; }
+ public string ConnectionString { get; set; }
- ///
- /// The assembly name where migrations are maintained for this context.
- ///
- public string MigrationsAssembly { get; set; }
- }
+ ///
+ /// The assembly name where migrations are maintained for this context.
+ ///
+ public string MigrationsAssembly { get; set; }
}
\ No newline at end of file
diff --git a/src/ExtCore.Data.EntityFramework/icon.png b/src/ExtCore.Data.EntityFramework/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data.EntityFramework/icon.png differ
diff --git a/src/ExtCore.Data/Actions/AddStorageAction.cs b/src/ExtCore.Data/Actions/AddStorageAction.cs
index af3acf3..883ed36 100644
--- a/src/ExtCore.Data/Actions/AddStorageAction.cs
+++ b/src/ExtCore.Data/Actions/AddStorageAction.cs
@@ -10,41 +10,40 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-namespace ExtCore.Data.Actions
+namespace ExtCore.Data.Actions;
+
+///
+/// Implements the IConfigureServicesAction interface and
+/// registers found implementation of the IStorage interface inside the DI.
+///
+public class AddStorageAction : IConfigureServicesAction
{
///
- /// Implements the IConfigureServicesAction interface and
- /// registers found implementation of the IStorage interface inside the DI.
+ /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
+ ///
+ public int Priority => 1000;
+
+ ///
+ /// Registers found implementation of the IStorage interface inside the DI.
///
- public class AddStorageAction : IConfigureServicesAction
+ ///
+ /// Will be provided by the ExtCore and might be used to register any service inside the DI.
+ ///
+ ///
+ /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
+ ///
+ public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
{
- ///
- /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
- ///
- public int Priority => 1000;
+ Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
- ///
- /// Registers found implementation of the IStorage interface inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to register any service inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
- ///
- public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
+ if (type == null)
{
- Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
+ ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.Data");
- if (type == null)
- {
- ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.Data");
-
- logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorage not found");
- return;
- }
-
- services.AddScoped(typeof(IStorage), type);
+ logger.LogError("Implementation of ExtCore.Data.Abstractions.IStorage not found");
+ return;
}
+
+ services.AddScoped(typeof(IStorage), type);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Data/ExtCore.Data.csproj b/src/ExtCore.Data/ExtCore.Data.csproj
index 76ea00d..dcd0e80 100644
--- a/src/ExtCore.Data/ExtCore.Data.csproj
+++ b/src/ExtCore.Data/ExtCore.Data.csproj
@@ -1,15 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Data
ExtCore.Data
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
diff --git a/src/ExtCore.Data/Extension.cs b/src/ExtCore.Data/Extension.cs
index 8d42f9f..4f244df 100644
--- a/src/ExtCore.Data/Extension.cs
+++ b/src/ExtCore.Data/Extension.cs
@@ -3,31 +3,30 @@
using ExtCore.Infrastructure;
-namespace ExtCore.Data
+namespace ExtCore.Data;
+
+///
+/// Overrides the ExtensionBase class and provides the ExtCore.Data extension information.
+///
+public class Extension : ExtensionBase
{
///
- /// Overrides the ExtensionBase class and provides the ExtCore.Data extension information.
+ /// Gets the name of the extension.
///
- public class Extension : ExtensionBase
- {
- ///
- /// Gets the name of the extension.
- ///
- public override string Name => "ExtCore.Data";
+ public override string Name => "ExtCore.Data";
- ///
- /// Gets the URL of the extension.
- ///
- public override string Url => "http://extcore.net/";
+ ///
+ /// Gets the URL of the extension.
+ ///
+ public override string Url => "https://extcore.net/";
- ///
- /// Gets the version of the extension.
- ///
- public override string Version => "4.1.0";
+ ///
+ /// Gets the version of the extension.
+ ///
+ public override string Version => "8.1.0";
- ///
- /// Gets the authors of the extension (separated by commas).
- ///
- public override string Authors => "Dmitry Sikorsky";
- }
+ ///
+ /// Gets the authors of the extension (separated by commas).
+ ///
+ public override string Authors => "Dmitry Sikorsky";
}
\ No newline at end of file
diff --git a/src/ExtCore.Data/icon.png b/src/ExtCore.Data/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Data/icon.png differ
diff --git a/src/ExtCore.Events/Event.cs b/src/ExtCore.Events/Event.cs
index 414c8d7..6b3e3e4 100644
--- a/src/ExtCore.Events/Event.cs
+++ b/src/ExtCore.Events/Event.cs
@@ -5,110 +5,109 @@
using System.Linq;
using ExtCore.Infrastructure;
-namespace ExtCore.Events
+namespace ExtCore.Events;
+
+///
+/// Represents an event that can be broadcasted and handled by the corresponding event handlers
+/// specified by the TEventHandler type parameter. The event handlers
+/// might be located in this or any other extension and will be resolved automatically by ExtCore.
+///
+/// Defines the type of the event handlers that will handle the event.
+public static class Event where TEventHandler : IEventHandler
{
///
- /// Represents an event that can be broadcasted and handled by the corresponding event handlers
- /// specified by the TEventHandler type parameter. The event handlers
- /// might be located in this or any other extension and will be resolved automatically by ExtCore.
+ /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
///
- /// Defines the type of the event handlers that will handle the event.
- public static class Event where TEventHandler : IEventHandler
+ /// Resolved event handlers that have handled the event.
+ public static IEnumerable Broadcast()
{
- ///
- /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
- ///
- /// Resolved event handlers that have handled the event.
- public static IEnumerable Broadcast()
- {
- IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
+ IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
- foreach (TEventHandler eventHandler in eventHandlers)
- eventHandler.HandleEvent();
+ foreach (TEventHandler eventHandler in eventHandlers)
+ eventHandler.HandleEvent();
- return eventHandlers;
- }
+ return eventHandlers;
}
+}
+///
+/// Represents an event that can be broadcasted and handled by the corresponding event handlers
+/// specified by the TEventHandler type parameter. The event handlers
+/// might be located in this or any other extension and will be resolved automatically by ExtCore.
+///
+/// Defines the type of the event handlers that will handle the event.
+/// Defines the type of the argument that will be passed to the event handlers.
+public static class Event where TEventHandler : IEventHandler
+{
///
- /// Represents an event that can be broadcasted and handled by the corresponding event handlers
- /// specified by the TEventHandler type parameter. The event handlers
- /// might be located in this or any other extension and will be resolved automatically by ExtCore.
+ /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
///
- /// Defines the type of the event handlers that will handle the event.
- /// Defines the type of the argument that will be passed to the event handlers.
- public static class Event where TEventHandler : IEventHandler
+ /// The event argument.
+ /// Resolved event handlers that have handled the event.
+ public static IEnumerable Broadcast(TEventArgument argument)
{
- ///
- /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
- ///
- /// The event argument.
- /// Resolved event handlers that have handled the event.
- public static IEnumerable Broadcast(TEventArgument argument)
- {
- IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
+ IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
- foreach (TEventHandler eventHandler in eventHandlers)
- eventHandler.HandleEvent(argument);
+ foreach (TEventHandler eventHandler in eventHandlers)
+ eventHandler.HandleEvent(argument);
- return eventHandlers;
- }
+ return eventHandlers;
}
+}
+///
+/// Represents an event that can be broadcasted and handled by the corresponding event handlers
+/// specified by the TEventHandler type parameter. The event handlers
+/// might be located in this or any other extension and will be resolved automatically by ExtCore.
+///
+///
+/// Defines the type of the event handlers that will handle the event.
+/// Defines the type of the first argument that will be passed to the event handlers.
+/// Defines the type of the second argument that will be passed to the event handlers.
+public static class Event where TEventHandler : IEventHandler
+{
///
- /// Represents an event that can be broadcasted and handled by the corresponding event handlers
- /// specified by the TEventHandler type parameter. The event handlers
- /// might be located in this or any other extension and will be resolved automatically by ExtCore.
+ /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
///
- ///
- /// Defines the type of the event handlers that will handle the event.
- /// Defines the type of the first argument that will be passed to the event handlers.
- /// Defines the type of the second argument that will be passed to the event handlers.
- public static class Event where TEventHandler : IEventHandler
+ /// The first event argument.
+ /// The second event argument.
+ /// Resolved event handlers that have handled the event.
+ public static IEnumerable Broadcast(TEventArgument1 argument1, TEventArgument2 argument2)
{
- ///
- /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
- ///
- /// The first event argument.
- /// The second event argument.
- /// Resolved event handlers that have handled the event.
- public static IEnumerable Broadcast(TEventArgument1 argument1, TEventArgument2 argument2)
- {
- IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
+ IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
- foreach (TEventHandler eventHandler in eventHandlers)
- eventHandler.HandleEvent(argument1, argument2);
+ foreach (TEventHandler eventHandler in eventHandlers)
+ eventHandler.HandleEvent(argument1, argument2);
- return eventHandlers;
- }
+ return eventHandlers;
}
+}
+///
+/// Represents an event that can be broadcasted and handled by the corresponding event handlers
+/// specified by the TEventHandler type parameter. The event handlers
+/// might be located in this or any other extension and will be resolved automatically by ExtCore.
+///
+/// Defines the type of the event handlers that will handle the event.
+/// Defines the type of the first argument that will be passed to the event handlers.
+/// Defines the type of the second argument that will be passed to the event handlers.
+/// Defines the type of the third argument that will be passed to the event handlers.
+public static class Event where TEventHandler : IEventHandler
+{
///
- /// Represents an event that can be broadcasted and handled by the corresponding event handlers
- /// specified by the TEventHandler type parameter. The event handlers
- /// might be located in this or any other extension and will be resolved automatically by ExtCore.
+ /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
///
- /// Defines the type of the event handlers that will handle the event.
- /// Defines the type of the first argument that will be passed to the event handlers.
- /// Defines the type of the second argument that will be passed to the event handlers.
- /// Defines the type of the third argument that will be passed to the event handlers.
- public static class Event where TEventHandler : IEventHandler
+ /// The first event argument.
+ /// The second event argument.
+ /// The third event argument.
+ /// Resolved event handlers that have handled the event.
+ public static IEnumerable Broadcast(TEventArgument1 argument1, TEventArgument2 argument2, TEventArgument3 argument3)
{
- ///
- /// Broadcasts the event to all the event handlers that are resolved automatically by ExtCore.
- ///
- /// The first event argument.
- /// The second event argument.
- /// The third event argument.
- /// Resolved event handlers that have handled the event.
- public static IEnumerable Broadcast(TEventArgument1 argument1, TEventArgument2 argument2, TEventArgument3 argument3)
- {
- IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
+ IEnumerable eventHandlers = ExtensionManager.GetInstances().OrderBy(eh => eh.Priority);
- foreach (TEventHandler eventHandler in eventHandlers)
- eventHandler.HandleEvent(argument1, argument2, argument3);
+ foreach (TEventHandler eventHandler in eventHandlers)
+ eventHandler.HandleEvent(argument1, argument2, argument3);
- return eventHandlers;
- }
+ return eventHandlers;
}
}
\ No newline at end of file
diff --git a/src/ExtCore.Events/ExtCore.Events.csproj b/src/ExtCore.Events/ExtCore.Events.csproj
index 20268db..6a91583 100644
--- a/src/ExtCore.Events/ExtCore.Events.csproj
+++ b/src/ExtCore.Events/ExtCore.Events.csproj
@@ -1,15 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Events extension component. Based on the ExtCore framework.
- 4.1.0
- netstandard2.0
+ net8.0
ExtCore.Events
ExtCore.Events
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
diff --git a/src/ExtCore.Events/Extension.cs b/src/ExtCore.Events/Extension.cs
index 1d05802..4207f4f 100644
--- a/src/ExtCore.Events/Extension.cs
+++ b/src/ExtCore.Events/Extension.cs
@@ -3,31 +3,30 @@
using ExtCore.Infrastructure;
-namespace ExtCore.Events
+namespace ExtCore.Events;
+
+///
+/// Overrides the ExtensionBase class and provides the ExtCore.Events extension information.
+///
+public class Extension : ExtensionBase
{
///
- /// Overrides the ExtensionBase class and provides the ExtCore.Events extension information.
+ /// Gets the name of the extension.
///
- public class Extension : ExtensionBase
- {
- ///
- /// Gets the name of the extension.
- ///
- public override string Name => "ExtCore.Events";
+ public override string Name => "ExtCore.Events";
- ///
- /// Gets the URL of the extension.
- ///
- public override string Url => "http://extcore.net/";
+ ///
+ /// Gets the URL of the extension.
+ ///
+ public override string Url => "https://extcore.net/";
- ///
- /// Gets the version of the extension.
- ///
- public override string Version => "4.1.0";
+ ///
+ /// Gets the version of the extension.
+ ///
+ public override string Version => "8.1.0";
- ///
- /// Gets the authors of the extension (separated by commas).
- ///
- public override string Authors => "Dmitry Sikorsky";
- }
+ ///
+ /// Gets the authors of the extension (separated by commas).
+ ///
+ public override string Authors => "Dmitry Sikorsky";
}
\ No newline at end of file
diff --git a/src/ExtCore.Events/IEventHandler.cs b/src/ExtCore.Events/IEventHandler.cs
index 30d8da6..3010b96 100644
--- a/src/ExtCore.Events/IEventHandler.cs
+++ b/src/ExtCore.Events/IEventHandler.cs
@@ -1,89 +1,88 @@
// Copyright © 2017 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.Events
+namespace ExtCore.Events;
+
+///
+/// Describes an event handler that can handle the events broadcasted by the
+/// class.
+///
+public interface IEventHandler
{
///
- /// Describes an event handler that can handle the events broadcasted by the
- /// class.
+ /// Priority of the event handler. The event handlers of the same event will be executed in the order
+ /// specified by the priority.
///
- public interface IEventHandler
- {
- ///
- /// Priority of the event handler. The event handlers of the same event will be executed in the order
- /// specified by the priority.
- ///
- int Priority { get; }
+ int Priority { get; }
- ///
- /// Handles the event.
- ///
- void HandleEvent();
- }
+ ///
+ /// Handles the event.
+ ///
+ void HandleEvent();
+}
+///
+/// Describes an event handler that can handle the events broadcasted by the
+/// class.
+///
+/// Defines the type of the argument that will be passed to the event handler.
+public interface IEventHandler
+{
///
- /// Describes an event handler that can handle the events broadcasted by the
- /// class.
+ /// Priority of the event handler. The event handlers of the same event will be executed in the order
+ /// specified by the priority.
///
- /// Defines the type of the argument that will be passed to the event handler.
- public interface IEventHandler
- {
- ///
- /// Priority of the event handler. The event handlers of the same event will be executed in the order
- /// specified by the priority.
- ///
- int Priority { get; }
+ int Priority { get; }
- ///
- /// Handles the event.
- ///
- /// The event argument.
- void HandleEvent(TEventArgument argument);
- }
+ ///
+ /// Handles the event.
+ ///
+ /// The event argument.
+ void HandleEvent(TEventArgument argument);
+}
+///
+/// Describes an event handler that can handle the events broadcasted by the
+/// class.
+///
+/// Defines the type of the first argument that will be passed to the event handler.
+/// Defines the type of the second argument that will be passed to the event handler.
+public interface IEventHandler
+{
///
- /// Describes an event handler that can handle the events broadcasted by the
- /// class.
+ /// Priority of the event handler. The event handlers of the same event will be executed in the order
+ /// specified by the priority.
///
- /// Defines the type of the first argument that will be passed to the event handler.
- /// Defines the type of the second argument that will be passed to the event handler.
- public interface IEventHandler
- {
- ///
- /// Priority of the event handler. The event handlers of the same event will be executed in the order
- /// specified by the priority.
- ///
- int Priority { get; }
+ int Priority { get; }
- ///
- /// Handles the event.
- ///
- /// The first event argument.
- /// The second event argument.
- void HandleEvent(TEventArgument1 argument1, TEventArgument2 argument2);
- }
+ ///
+ /// Handles the event.
+ ///
+ /// The first event argument.
+ /// The second event argument.
+ void HandleEvent(TEventArgument1 argument1, TEventArgument2 argument2);
+}
+///
+/// Describes an event handler that can handle the events broadcasted by the
+/// class.
+///
+/// Defines the type of the first argument that will be passed to the event handler.
+/// Defines the type of the second argument that will be passed to the event handler.
+/// Defines the type of the first argument that will be passed to the event handler.
+public interface IEventHandler
+{
///
- /// Describes an event handler that can handle the events broadcasted by the
- /// class.
+ /// Priority of the event handler. The event handlers of the same event will be executed in the order
+ /// specified by the priority.
///
- /// Defines the type of the first argument that will be passed to the event handler.
- /// Defines the type of the second argument that will be passed to the event handler.
- /// Defines the type of the first argument that will be passed to the event handler.
- public interface IEventHandler
- {
- ///
- /// Priority of the event handler. The event handlers of the same event will be executed in the order
- /// specified by the priority.
- ///
- int Priority { get; }
+ int Priority { get; }
- ///
- /// Handles the event.
- ///
- /// The first event argument.
- /// The second event argument.
- /// The third event argument.
- void HandleEvent(TEventArgument1 argument1, TEventArgument2 argument2, TEventArgument3 argument3);
- }
+ ///
+ /// Handles the event.
+ ///
+ /// The first event argument.
+ /// The second event argument.
+ /// The third event argument.
+ void HandleEvent(TEventArgument1 argument1, TEventArgument2 argument2, TEventArgument3 argument3);
}
\ No newline at end of file
diff --git a/src/ExtCore.Events/icon.png b/src/ExtCore.Events/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.Events/icon.png differ
diff --git a/src/ExtCore.FileStorage.Abstractions/Exceptions/AccessDeniedException.cs b/src/ExtCore.FileStorage.Abstractions/Exceptions/AccessDeniedException.cs
index 16bde33..389e6b7 100644
--- a/src/ExtCore.FileStorage.Abstractions/Exceptions/AccessDeniedException.cs
+++ b/src/ExtCore.FileStorage.Abstractions/Exceptions/AccessDeniedException.cs
@@ -3,15 +3,14 @@
using System;
-namespace ExtCore.FileStorage
+namespace ExtCore.FileStorage;
+
+///
+/// Represents an access denied file storage exception.
+///
+public class AccessDeniedException : FileStorageException
{
- ///
- /// Represents an access denied file storage exception.
- ///
- public class AccessDeniedException : FileStorageException
- {
- public AccessDeniedException() : base() { }
- public AccessDeniedException(string message) : base(message) { }
- public AccessDeniedException(string message, Exception innerException) : base(message, innerException) { }
- }
+ public AccessDeniedException() : base() { }
+ public AccessDeniedException(string message) : base(message) { }
+ public AccessDeniedException(string message, Exception innerException) : base(message, innerException) { }
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/Exceptions/DirectoryNotFoundException.cs b/src/ExtCore.FileStorage.Abstractions/Exceptions/DirectoryNotFoundException.cs
index 8a925b4..0584731 100644
--- a/src/ExtCore.FileStorage.Abstractions/Exceptions/DirectoryNotFoundException.cs
+++ b/src/ExtCore.FileStorage.Abstractions/Exceptions/DirectoryNotFoundException.cs
@@ -3,15 +3,14 @@
using System;
-namespace ExtCore.FileStorage
+namespace ExtCore.FileStorage;
+
+///
+/// Represents a directory not found file storage exception.
+///
+public class DirectoryNotFoundException : FileStorageException
{
- ///
- /// Represents a directory not found file storage exception.
- ///
- public class DirectoryNotFoundException : FileStorageException
- {
- public DirectoryNotFoundException() : base() { }
- public DirectoryNotFoundException(string message) : base(message) { }
- public DirectoryNotFoundException(string message, Exception innerException) : base(message, innerException) { }
- }
+ public DirectoryNotFoundException() : base() { }
+ public DirectoryNotFoundException(string message) : base(message) { }
+ public DirectoryNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/Exceptions/FileNotFoundException.cs b/src/ExtCore.FileStorage.Abstractions/Exceptions/FileNotFoundException.cs
index 6d5c4d0..f4d1dbc 100644
--- a/src/ExtCore.FileStorage.Abstractions/Exceptions/FileNotFoundException.cs
+++ b/src/ExtCore.FileStorage.Abstractions/Exceptions/FileNotFoundException.cs
@@ -3,15 +3,14 @@
using System;
-namespace ExtCore.FileStorage
+namespace ExtCore.FileStorage;
+
+///
+/// Represents a directory not found file storage exception.
+///
+public class FileNotFoundException : FileStorageException
{
- ///
- /// Represents a directory not found file storage exception.
- ///
- public class FileNotFoundException : FileStorageException
- {
- public FileNotFoundException() : base() { }
- public FileNotFoundException(string message) : base(message) { }
- public FileNotFoundException(string message, Exception innerException) : base(message, innerException) { }
- }
+ public FileNotFoundException() : base() { }
+ public FileNotFoundException(string message) : base(message) { }
+ public FileNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/Exceptions/FileStorageException.cs b/src/ExtCore.FileStorage.Abstractions/Exceptions/FileStorageException.cs
index c0d203a..11d5c24 100644
--- a/src/ExtCore.FileStorage.Abstractions/Exceptions/FileStorageException.cs
+++ b/src/ExtCore.FileStorage.Abstractions/Exceptions/FileStorageException.cs
@@ -3,15 +3,14 @@
using System;
-namespace ExtCore.FileStorage
+namespace ExtCore.FileStorage;
+
+///
+/// Represents a generic file storage exception.
+///
+public class FileStorageException : Exception
{
- ///
- /// Represents a generic file storage exception.
- ///
- public class FileStorageException : Exception
- {
- public FileStorageException() : base() { }
- public FileStorageException(string message) : base(message) { }
- public FileStorageException(string message, Exception innerException) : base(message, innerException) { }
- }
+ public FileStorageException() : base() { }
+ public FileStorageException(string message) : base(message) { }
+ public FileStorageException(string message, Exception innerException) : base(message, innerException) { }
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/Exceptions/PathTooLongException.cs b/src/ExtCore.FileStorage.Abstractions/Exceptions/PathTooLongException.cs
index bf360fe..9d6e1aa 100644
--- a/src/ExtCore.FileStorage.Abstractions/Exceptions/PathTooLongException.cs
+++ b/src/ExtCore.FileStorage.Abstractions/Exceptions/PathTooLongException.cs
@@ -3,15 +3,14 @@
using System;
-namespace ExtCore.FileStorage
+namespace ExtCore.FileStorage;
+
+///
+/// Represents a path too long file storage exception.
+///
+public class PathTooLongException : FileStorageException
{
- ///
- /// Represents a path too long file storage exception.
- ///
- public class PathTooLongException : FileStorageException
- {
- public PathTooLongException() : base() { }
- public PathTooLongException(string message) : base(message) { }
- public PathTooLongException(string message, Exception innerException) : base(message, innerException) { }
- }
+ public PathTooLongException() : base() { }
+ public PathTooLongException(string message) : base(message) { }
+ public PathTooLongException(string message, Exception innerException) : base(message, innerException) { }
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/ExtCore.FileStorage.Abstractions.csproj b/src/ExtCore.FileStorage.Abstractions/ExtCore.FileStorage.Abstractions.csproj
index 2a4fe80..84dc73d 100644
--- a/src/ExtCore.FileStorage.Abstractions/ExtCore.FileStorage.Abstractions.csproj
+++ b/src/ExtCore.FileStorage.Abstractions/ExtCore.FileStorage.Abstractions.csproj
@@ -1,15 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 4.1.0
netstandard2.0
ExtCore.FileStorage.Abstractions
ExtCore.FileStorage.Abstractions
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
diff --git a/src/ExtCore.FileStorage.Abstractions/FileStorageOptions.cs b/src/ExtCore.FileStorage.Abstractions/FileStorageOptions.cs
index b480954..47c466d 100644
--- a/src/ExtCore.FileStorage.Abstractions/FileStorageOptions.cs
+++ b/src/ExtCore.FileStorage.Abstractions/FileStorageOptions.cs
@@ -1,31 +1,30 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.FileStorage
+namespace ExtCore.FileStorage;
+
+///
+/// Represents generic file storage options.
+///
+public class FileStorageOptions
{
///
- /// Represents generic file storage options.
+ /// The origin that is used to connect to the file storage. Might be used to provide an API base URL.
///
- public class FileStorageOptions
- {
- ///
- /// The origin that is used to connect to the file storage. Might be used to provide an API base URL.
- ///
- public string Origin { get; set; }
+ public string Origin { get; set; }
- ///
- /// The identifier that is used to connect to the file storage. Might be used to provide a username or an application identifier.
- ///
- public string Identifier { get; set; }
+ ///
+ /// The identifier that is used to connect to the file storage. Might be used to provide a username or an application identifier.
+ ///
+ public string Identifier { get; set; }
- ///
- /// The secret that is used to connect to the file storage. Might be used to provide a password, an application secret, or an API key.
- ///
- public string Secret { get; set; }
+ ///
+ /// The secret that is used to connect to the file storage. Might be used to provide a password, an application secret, or an API key.
+ ///
+ public string Secret { get; set; }
- ///
- /// The root path that is used by the file storage.
- ///
- public string RootPath { get; set; }
- }
+ ///
+ /// The root path that is used by the file storage.
+ ///
+ public string RootPath { get; set; }
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/IDirectoryProxy.cs b/src/ExtCore.FileStorage.Abstractions/IDirectoryProxy.cs
index 501ac60..f504af5 100644
--- a/src/ExtCore.FileStorage.Abstractions/IDirectoryProxy.cs
+++ b/src/ExtCore.FileStorage.Abstractions/IDirectoryProxy.cs
@@ -5,73 +5,72 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-namespace ExtCore.FileStorage.Abstractions
+namespace ExtCore.FileStorage.Abstractions;
+
+///
+/// Describes a generic directory proxy to manipulate an underlying directory with a specified relative path.
+///
+public interface IDirectoryProxy
{
///
- /// Describes a generic directory proxy to manipulate an underlying directory with a specified relative path.
+ /// The path of the underlying directory relatively to the root one.
///
- public interface IDirectoryProxy
- {
- ///
- /// The path of the underlying directory relatively to the root one.
- ///
- string RelativePath { get; }
+ string RelativePath { get; }
- ///
- /// Checks if the underlying directory exists.
- ///
- /// Returns a flag indicating if the underlying directory exists.
- Task ExistsAsync();
+ ///
+ /// Checks if the underlying directory exists.
+ ///
+ /// Returns a flag indicating if the underlying directory exists.
+ Task ExistsAsync();
- ///
- /// Creates the underlying directory.
- ///
- ///
- ///
- ///
- ///
- Task CreateAsync();
+ ///
+ /// Creates the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task CreateAsync();
- ///
- /// Moves the underlying directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- Task MoveAsync(string destinationRelativePath);
+ ///
+ /// Moves the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task MoveAsync(string destinationRelativePath);
- ///
- /// Deletes the underlying directory.
- ///
- /// Pass true to remove all the underlying directory content recursively; otherwise false.
- ///
- ///
- ///
- ///
- Task DeleteAsync(bool recursive);
+ ///
+ /// Deletes the underlying directory.
+ ///
+ /// Pass true to remove all the underlying directory content recursively; otherwise false.
+ ///
+ ///
+ ///
+ ///
+ Task DeleteAsync(bool recursive);
- ///
- /// Gets the directory proxies for the directories inside the underlying one.
- ///
- /// The directory proxies for the directories inside the underlying one
- ///
- ///
- ///
- ///
- Task> GetDirectoryProxiesAsync();
+ ///
+ /// Gets the directory proxies for the directories inside the underlying one.
+ ///
+ /// The directory proxies for the directories inside the underlying one
+ ///
+ ///
+ ///
+ ///
+ Task> GetDirectoryProxiesAsync();
- ///
- /// Gets the file proxies for the files inside the underlying one.
- ///
- /// The file proxies for the files inside the underlying directory.
- ///
- ///
- ///
- ///
- Task> GetFileProxiesAsync();
- }
+ ///
+ /// Gets the file proxies for the files inside the underlying one.
+ ///
+ /// The file proxies for the files inside the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ Task> GetFileProxiesAsync();
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/IFileProxy.cs b/src/ExtCore.FileStorage.Abstractions/IFileProxy.cs
index 059392a..c006c7f 100644
--- a/src/ExtCore.FileStorage.Abstractions/IFileProxy.cs
+++ b/src/ExtCore.FileStorage.Abstractions/IFileProxy.cs
@@ -5,103 +5,102 @@
using System.IO;
using System.Threading.Tasks;
-namespace ExtCore.FileStorage.Abstractions
+namespace ExtCore.FileStorage.Abstractions;
+
+///
+/// Describes a generic file proxy to manipulate an underlying file with a specified relative path and a filename.
+///
+public interface IFileProxy
{
///
- /// Describes a generic file proxy to manipulate an underlying file with a specified relative path and a filename.
+ /// The path of the underlying file relatively to the root one.
///
- public interface IFileProxy
- {
- ///
- /// The path of the underlying file relatively to the root one.
- ///
- string RelativePath { get; }
+ string RelativePath { get; }
- ///
- /// The filename of the underlying file.
- ///
- string Filename { get; }
+ ///
+ /// The filename of the underlying file.
+ ///
+ string Filename { get; }
- ///
- /// Checks if the underlying file exists.
- ///
- /// Returns a flag indicating if the underlying file exists.
- Task ExistsAsync();
+ ///
+ /// Checks if the underlying file exists.
+ ///
+ /// Returns a flag indicating if the underlying file exists.
+ Task ExistsAsync();
- ///
- /// Reads content of the underlying file as a stream.
- ///
- /// Content of the underlying file as a stream.
- ///
- ///
- ///
- ///
- ///
- Task ReadStreamAsync();
+ ///
+ /// Reads content of the underlying file as a stream.
+ ///
+ /// Content of the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task ReadStreamAsync();
- ///
- /// Reads content of the underlying file as a byte array.
- ///
- /// Content of the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- Task ReadBytesAsync();
+ ///
+ /// Reads content of the underlying file as a byte array.
+ ///
+ /// Content of the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task ReadBytesAsync();
- ///
- /// Reads content of the underlying file as a text string.
- ///
- /// Content of the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- Task ReadTextAsync();
+ ///
+ /// Reads content of the underlying file as a text string.
+ ///
+ /// Content of the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task ReadTextAsync();
- ///
- /// Writes content to the underlying file as a stream.
- ///
- /// Content to write to the underlying file as a stream.
- ///
- ///
- ///
- ///
- ///
- Task WriteStreamAsync(Stream inputStream);
+ ///
+ /// Writes content to the underlying file as a stream.
+ ///
+ /// Content to write to the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task WriteStreamAsync(Stream inputStream);
- ///
- /// Writes content to the underlying file as a byte array.
- ///
- /// Content to write to the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- Task WriteBytesAsync(byte[] bytes);
+ ///
+ /// Writes content to the underlying file as a byte array.
+ ///
+ /// Content to write to the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task WriteBytesAsync(byte[] bytes);
- ///
- /// Writes content to the underlying file as a text string.
- ///
- /// Content to write to the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- Task WriteTextAsync(string text);
+ ///
+ /// Writes content to the underlying file as a text string.
+ ///
+ /// Content to write to the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task WriteTextAsync(string text);
- ///
- /// Deletes the underlying file.
- ///
- ///
- ///
- ///
- ///
- ///
- Task DeleteAsync();
- }
+ ///
+ /// Deletes the underlying file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task DeleteAsync();
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/IFileStorage.cs b/src/ExtCore.FileStorage.Abstractions/IFileStorage.cs
index 72b4cc8..722958a 100644
--- a/src/ExtCore.FileStorage.Abstractions/IFileStorage.cs
+++ b/src/ExtCore.FileStorage.Abstractions/IFileStorage.cs
@@ -1,26 +1,25 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-namespace ExtCore.FileStorage.Abstractions
+namespace ExtCore.FileStorage.Abstractions;
+
+///
+/// Describes a generic file storage that allows to manipulate directories and files via proxies.
+///
+public interface IFileStorage
{
///
- /// Describes a generic file storage that allows to manipulate directories and files via proxies.
+ /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
///
- public interface IFileStorage
- {
- ///
- /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
- ///
- /// The path of the underlying directory relatively to the root one.
- /// Created directory proxy.
- IDirectoryProxy CreateDirectoryProxy(string relativePath);
+ /// The path of the underlying directory relatively to the root one.
+ /// Created directory proxy.
+ IDirectoryProxy CreateDirectoryProxy(string relativePath);
- ///
- /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
- ///
- /// The path of the underlying file relatively to the root one.
- /// The filename of the underlying file.
- /// Created file proxy.
- IFileProxy CreateFileProxy(string relativePath, string filename);
- }
+ ///
+ /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
+ ///
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ /// Created file proxy.
+ IFileProxy CreateFileProxy(string relativePath, string filename);
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Abstractions/icon.png b/src/ExtCore.FileStorage.Abstractions/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.FileStorage.Abstractions/icon.png differ
diff --git a/src/ExtCore.FileStorage.Azure/DirectoryProxy.cs b/src/ExtCore.FileStorage.Azure/DirectoryProxy.cs
new file mode 100644
index 0000000..d6b474b
--- /dev/null
+++ b/src/ExtCore.FileStorage.Azure/DirectoryProxy.cs
@@ -0,0 +1,224 @@
+// Copyright © 2022 Dmitry Sikorsky. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Azure;
+using Azure.Storage.Blobs;
+using Azure.Storage.Blobs.Models;
+using ExtCore.FileStorage.Abstractions;
+
+namespace ExtCore.FileStorage.Azure;
+
+///
+/// Implements the IDirectoryProxy interface and represents a directory in a Azure Storage account.
+///
+public class DirectoryProxy : IDirectoryProxy
+{
+ private readonly string connectionString;
+ private readonly string rootPath;
+ private readonly string path;
+ private readonly string containerName;
+ private readonly string prefix;
+
+ ///
+ /// The path of the underlying directory relatively to the root one.
+ ///
+ public string RelativePath { get; private set; }
+
+ ///
+ /// Initializes a new instance of the DirectoryProxy class.
+ ///
+ /// The Azure Storage account connection string.
+ /// The root path of the underlying directory's relative one.
+ /// The path of the underlying directory relatively to the root one.
+ ///
+ ///
+ public DirectoryProxy(string connectionString, string rootPath, string relativePath)
+ {
+ if (connectionString == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: connectionString.");
+
+ if (connectionString == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: connectionString.", default(Exception));
+
+ this.connectionString = connectionString;
+ this.rootPath = RelativeUrl.Combine(rootPath);
+ this.RelativePath = RelativeUrl.Combine(relativePath);
+ this.path = RelativeUrl.Combine(this.rootPath, this.RelativePath);
+
+ string[] urlSegments = path.Split('/');
+
+ this.containerName = urlSegments.First();
+ this.prefix = string.Join("/", urlSegments.Skip(1));
+ }
+
+ ///
+ /// Checks if the underlying directory exists.
+ ///
+ /// Returns a flag indicating if the underlying directory exists.
+ public async Task ExistsAsync()
+ {
+ try
+ {
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+ IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: this.prefix).AsPages();
+
+ await foreach (Page page in pages)
+ return page.Values.Count != 0;
+ }
+
+ catch { }
+
+ return false;
+ }
+
+ ///
+ /// Creates the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task CreateAsync()
+ {
+ throw new NotSupportedException();
+ }
+
+ ///
+ /// Moves the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task MoveAsync(string destinationRelativePath)
+ {
+ throw new NotSupportedException();
+ }
+
+ ///
+ /// Deletes the underlying directory.
+ ///
+ /// Pass true to remove all the underlying directory content recursively; otherwise false.
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync(bool recursive)
+ {
+ try
+ {
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+
+ if (string.IsNullOrEmpty(this.prefix))
+ {
+ await blobContainerClient.DeleteAsync();
+ return;
+ }
+
+ string prefix = this.prefix + "/";
+ IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: recursive ? null : "/").AsPages();
+
+ await foreach (Page page in pages)
+ {
+ foreach (BlobHierarchyItem blobItem in page.Values)
+ {
+ if (blobItem.IsBlob)
+ {
+ BlobClient blobClient = await this.GetBlobClient(blobItem.Blob);
+
+ await blobClient.DeleteAsync();
+ }
+ }
+ }
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Gets the directory proxies for the directories inside the underlying one.
+ ///
+ /// The directory proxies for the directories inside the underlying one
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetDirectoryProxiesAsync()
+ {
+ try
+ {
+ IList directoryProxies = new List();
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+ string prefix = string.IsNullOrEmpty(this.prefix) ? null : this.prefix + "/";
+ IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: "/").AsPages();
+
+ await foreach (Page page in pages)
+ foreach (BlobHierarchyItem blobItem in page.Values)
+ if (blobItem.IsPrefix)
+ directoryProxies.Add(new DirectoryProxy(this.connectionString, this.rootPath, RelativeUrl.Combine(this.RelativePath, RelativeUrl.Combine(blobItem.Prefix).Split('/').Last())));
+
+ return directoryProxies;
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Gets the file proxies for the files inside the underlying one.
+ ///
+ /// The file proxies for the files inside the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetFileProxiesAsync()
+ {
+ try
+ {
+ IList fileProxies = new List();
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+ string prefix = string.IsNullOrEmpty(this.prefix) ? null : this.prefix + "/";
+ IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: "/").AsPages();
+
+ await foreach (Page page in pages)
+ foreach (BlobHierarchyItem blobItem in page.Values)
+ if (blobItem.IsBlob)
+ fileProxies.Add(new FileProxy(this.connectionString, this.rootPath, this.RelativePath, blobItem.Blob.Name.Split('/').Last()));
+
+ return fileProxies;
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
+
+ private BlobContainerClient GetBlobContainerClient()
+ {
+ BlobServiceClient blobServiceClient = new BlobServiceClient(this.connectionString);
+
+ return blobServiceClient.GetBlobContainerClient(this.containerName);
+ }
+
+ private async Task GetBlobClient(BlobItem blobItem)
+ {
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+
+ await blobContainerClient.CreateIfNotExistsAsync();
+ return blobContainerClient.GetBlobClient(blobItem.Name);
+ }
+}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Azure/ExtCore.FileStorage.Azure.csproj b/src/ExtCore.FileStorage.Azure/ExtCore.FileStorage.Azure.csproj
new file mode 100644
index 0000000..07eb781
--- /dev/null
+++ b/src/ExtCore.FileStorage.Azure/ExtCore.FileStorage.Azure.csproj
@@ -0,0 +1,21 @@
+
+
+
+
+ The ExtCore.FileStorage extension component. Based on the ExtCore framework.
+ netstandard2.0
+ ExtCore.FileStorage.Azure
+ ExtCore.FileStorage.Azure
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ExtCore.FileStorage.Azure/FileProxy.cs b/src/ExtCore.FileStorage.Azure/FileProxy.cs
new file mode 100644
index 0000000..9fced27
--- /dev/null
+++ b/src/ExtCore.FileStorage.Azure/FileProxy.cs
@@ -0,0 +1,267 @@
+// Copyright © 2022 Dmitry Sikorsky. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+using Azure.Storage.Blobs;
+using Azure.Storage.Blobs.Models;
+using ExtCore.FileStorage.Abstractions;
+
+namespace ExtCore.FileStorage.Azure;
+
+///
+/// Implements the IDirectoryProxy interface and represents a file in a Azure Storage account.
+///
+public class FileProxy : IFileProxy
+{
+ private readonly string connectionString;
+ private readonly string filepath;
+ private readonly string containerName;
+ private readonly string blobName;
+
+ ///
+ /// The path of the underlying file relatively to the root one.
+ ///
+ public string RelativePath { get; private set; }
+
+ ///
+ /// The filename of the underlying file.
+ ///
+ public string Filename { get; private set; }
+
+ ///
+ /// Initializes a new instance of the FileProxy class.
+ ///
+ /// The Azure Storage account connection string.
+ /// The root path of the underlying file's relative one.
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ ///
+ ///
+ public FileProxy(string connectionString, string rootPath, string relativePath, string filename)
+ {
+ if (connectionString == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: connectionString.");
+
+ if (connectionString == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: connectionString.", default(Exception));
+
+ if (filename == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: filename.");
+
+ if (filename == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: filename.", default(Exception));
+
+ this.connectionString = connectionString;
+ this.RelativePath = RelativeUrl.Combine(relativePath);
+ this.Filename = filename;
+ this.filepath = RelativeUrl.Combine(rootPath, this.RelativePath, this.Filename);
+
+ string[] urlSegments = filepath.Split('/');
+
+ this.containerName = urlSegments.First();
+ this.blobName = string.Join("/", urlSegments.Skip(1));
+ }
+
+ ///
+ /// Checks if the underlying file exists.
+ ///
+ /// Returns a flag indicating if the underlying file exists.
+ public async Task ExistsAsync()
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+
+ return await blobClient.ExistsAsync();
+ }
+
+ catch
+ {
+ return false;
+ }
+ }
+
+ ///
+ /// Reads content of the underlying file as a byte array.
+ ///
+ /// Content of the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadStreamAsync()
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+ MemoryStream stream = new MemoryStream();
+
+ await blobClient.DownloadToAsync(stream);
+ stream.Position = 0;
+ return stream;
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Reads content of the underlying file as a byte array.
+ ///
+ /// Content of the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadBytesAsync()
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+ BlobDownloadResult downloadResult = await blobClient.DownloadContentAsync();
+
+ return downloadResult.Content.ToArray();
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Reads content of the underlying file as a text string.
+ ///
+ /// Content of the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadTextAsync()
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+ BlobDownloadResult downloadResult = await blobClient.DownloadContentAsync();
+
+ return downloadResult.Content.ToString();
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Writes content to the underlying file as a stream.
+ ///
+ /// Content to write to the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteStreamAsync(Stream inputStream)
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+
+ await blobClient.UploadAsync(inputStream);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Writes content to the underlying file as a byte array.
+ ///
+ /// Content to write to the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteBytesAsync(byte[] bytes)
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+
+ await blobClient.UploadAsync(BinaryData.FromBytes(bytes));
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Writes content to the underlying file as a text string.
+ ///
+ /// Content to write to the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteTextAsync(string text)
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+
+ await blobClient.UploadAsync(BinaryData.FromString(text));
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ ///
+ /// Deletes the underlying file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync()
+ {
+ try
+ {
+ BlobClient blobClient = await this.GetBlobClient();
+
+ await blobClient.DeleteAsync();
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ }
+
+ private async Task GetBlobClient()
+ {
+ BlobServiceClient blobServiceClient = new BlobServiceClient(this.connectionString);
+ BlobContainerClient blobContainerClient = blobServiceClient.GetBlobContainerClient(this.containerName);
+
+ await blobContainerClient.CreateIfNotExistsAsync();
+ return blobContainerClient.GetBlobClient(this.blobName);
+ }
+}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Azure/FileStorage.cs b/src/ExtCore.FileStorage.Azure/FileStorage.cs
new file mode 100644
index 0000000..b5a9b2b
--- /dev/null
+++ b/src/ExtCore.FileStorage.Azure/FileStorage.cs
@@ -0,0 +1,47 @@
+// Copyright © 2022 Dmitry Sikorsky. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using ExtCore.FileStorage.Abstractions;
+using Microsoft.Extensions.Options;
+
+namespace ExtCore.FileStorage.Azure;
+
+///
+/// Implements the IFileStorage interface and represents a file storage in a Azure Storage account.
+///
+public class FileStorage : IFileStorage
+{
+ private readonly string secret;
+ private readonly string rootPath;
+
+ ///
+ /// Initializes a new instance of the FileStorage class.
+ ///
+ /// The options that are used to configure the file storage root path.
+ public FileStorage(IOptions options)
+ {
+ this.secret = options.Value.Secret;
+ this.rootPath = options.Value.RootPath;
+ }
+
+ ///
+ /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
+ ///
+ /// The path of the underlying directory relatively to the root one.
+ /// Created directory proxy.
+ public IDirectoryProxy CreateDirectoryProxy(string relativePath)
+ {
+ return new DirectoryProxy(this.secret, this.rootPath, relativePath);
+ }
+
+ ///
+ /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
+ ///
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ /// Created file proxy.
+ public IFileProxy CreateFileProxy(string relativePath, string filename)
+ {
+ return new FileProxy(this.secret, this.rootPath, relativePath, filename);
+ }
+}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Azure/RelativeUrl.cs b/src/ExtCore.FileStorage.Azure/RelativeUrl.cs
new file mode 100644
index 0000000..539139f
--- /dev/null
+++ b/src/ExtCore.FileStorage.Azure/RelativeUrl.cs
@@ -0,0 +1,20 @@
+// Copyright © 2022 Dmitry Sikorsky. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Linq;
+
+namespace ExtCore.FileStorage.Azure;
+
+public static class RelativeUrl
+{
+ public static string Combine(params string[] segments)
+ {
+ return string.Join(
+ "/",
+ segments.Where(s => !string.IsNullOrEmpty(s)).Select(
+ s => string.Join("/", s.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries))
+ ).Where(s => !string.IsNullOrEmpty(s))
+ );
+ }
+}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Azure/icon.png b/src/ExtCore.FileStorage.Azure/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.FileStorage.Azure/icon.png differ
diff --git a/src/ExtCore.FileStorage.Dropbox/DirectoryProxy.cs b/src/ExtCore.FileStorage.Dropbox/DirectoryProxy.cs
index bfb15f1..f18de8c 100644
--- a/src/ExtCore.FileStorage.Dropbox/DirectoryProxy.cs
+++ b/src/ExtCore.FileStorage.Dropbox/DirectoryProxy.cs
@@ -9,144 +9,178 @@
using Dropbox.Api.Files;
using ExtCore.FileStorage.Abstractions;
-namespace ExtCore.FileStorage.Dropbox
+namespace ExtCore.FileStorage.Dropbox;
+
+///
+/// Implements the IDirectoryProxy interface and represents a directory in a Dropbox account.
+///
+public class DirectoryProxy : IDirectoryProxy
{
+ private readonly string accessToken;
+ private readonly string rootPath;
+ private readonly string path;
+
///
- /// Implements the IDirectoryProxy interface and represents a directory in a Dropbox account.
+ /// The path of the underlying directory relatively to the root one.
///
- public class DirectoryProxy : IDirectoryProxy
+ public string RelativePath { get; private set; }
+
+ ///
+ /// Initializes a new instance of the DirectoryProxy class.
+ ///
+ /// The Dropbox's account access token.
+ /// The root path of the underlying directory's relative one.
+ /// The path of the underlying directory relatively to the root one.
+ ///
+ ///
+ public DirectoryProxy(string accessToken, string rootPath, string relativePath)
{
- private readonly string accessToken;
- private readonly string rootPath;
- private readonly string path;
-
- ///
- /// The path of the underlying directory relatively to the root one.
- ///
- public string RelativePath { get; private set; }
-
- ///
- /// Initializes a new instance of the DirectoryProxy class.
- ///
- /// The Dropbox's account access token.
- /// The root path of the underlying directory's relative one.
- /// The path of the underlying directory relatively to the root one.
- ///
- ///
- public DirectoryProxy(string accessToken, string rootPath, string relativePath)
- {
- if (accessToken == string.Empty)
- throw new ArgumentException($"Value can't be empty. Parameter name: accessToken.");
+ if (accessToken == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: accessToken.");
- if (accessToken == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: accessToken.", default(Exception));
+ if (accessToken == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: accessToken.", default(Exception));
- this.accessToken = accessToken;
- this.rootPath = RelativeUrl.Combine(rootPath);
- this.RelativePath = RelativeUrl.Combine(relativePath);
- this.path = RelativeUrl.Combine(this.rootPath, this.RelativePath);
+ this.accessToken = accessToken;
+ this.rootPath = RelativeUrl.Combine(rootPath);
+ this.RelativePath = RelativeUrl.Combine(relativePath);
+ this.path = RelativeUrl.Combine(this.rootPath, this.RelativePath);
- if (string.Equals(this.path, "/"))
- this.path = string.Empty;
- }
+ if (string.Equals(this.path, "/"))
+ this.path = string.Empty;
+ }
- ///
- /// Checks if the underlying directory exists.
- ///
- /// Returns a flag indicating if the underlying directory exists.
- public async Task ExistsAsync()
+ ///
+ /// Checks if the underlying directory exists.
+ ///
+ /// Returns a flag indicating if the underlying directory exists.
+ public async Task ExistsAsync()
+ {
+ try
{
- try
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
{
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- {
- Metadata metadata = await dropboxClient.Files.GetMetadataAsync(this.path);
+ Metadata metadata = await dropboxClient.Files.GetMetadataAsync(this.path);
- return metadata.IsFolder;
- }
+ return metadata.IsFolder;
}
+ }
+
+ catch { return false; }
+ }
- catch { return false; }
+ ///
+ /// Creates the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task CreateAsync()
+ {
+ try
+ {
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ await dropboxClient.Files.CreateFolderV2Async(this.path);
}
- ///
- /// Creates the underlying directory.
- ///
- ///
- ///
- ///
- ///
- public async Task CreateAsync()
+ catch (Exception e)
{
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- await dropboxClient.Files.CreateFolderV2Async(this.path);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ ///
+ /// Moves the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task MoveAsync(string destinationRelativePath)
+ {
+ if (destinationRelativePath == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: destinationRelativePath.");
+
+ if (destinationRelativePath == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: destinationRelativePath.", default(Exception));
+
+ try
+ {
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ await dropboxClient.Files.MoveV2Async(this.path, RelativeUrl.Combine(this.rootPath, destinationRelativePath));
}
- ///
- /// Moves the underlying directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task MoveAsync(string destinationRelativePath)
+ catch (ApiException e)
{
- if (destinationRelativePath == string.Empty)
- throw new ArgumentException($"Value can't be empty. Parameter name: destinationRelativePath.");
+ if (e.ErrorResponse.IsFromLookup)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
- if (destinationRelativePath == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: destinationRelativePath.", default(Exception));
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- await dropboxClient.Files.MoveV2Async(this.path, RelativeUrl.Combine(this.rootPath, destinationRelativePath));
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsFromLookup)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
+ ///
+ /// Deletes the underlying directory.
+ ///
+ /// Pass true to remove all the underlying directory content recursively; otherwise false.
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync(bool recursive)
+ {
+ try
+ {
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ await dropboxClient.Files.DeleteV2Async(this.path);
+ }
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ catch (ApiException e)
+ {
+ if (e.ErrorResponse.IsPathLookup)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
}
+ }
- ///
- /// Deletes the underlying directory.
- ///
- /// Pass true to remove all the underlying directory content recursively; otherwise false.
- ///
- ///
- ///
- ///
- public async Task DeleteAsync(bool recursive)
+ ///
+ /// Gets the directory proxies for the directories inside the underlying one.
+ ///
+ /// The directory proxies for the directories inside the underlying one
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetDirectoryProxiesAsync()
+ {
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
{
+ IList directoryProxies = new List();
+
try
{
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- await dropboxClient.Files.DeleteV2Async(this.path);
+ foreach (Metadata metadata in (await dropboxClient.Files.ListFolderAsync(this.path)).Entries.Where(m => m.IsFolder))
+ directoryProxies.Add(new DirectoryProxy(this.accessToken, this.rootPath, metadata.PathDisplay.Substring(this.rootPath.Length)));
}
- catch (ApiException e)
+ catch (ApiException e)
{
- if (e.ErrorResponse.IsPathLookup)
+ if (e.ErrorResponse.IsPath)
throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
@@ -156,89 +190,54 @@ public async Task DeleteAsync(bool recursive)
{
throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
}
+
+ return directoryProxies;
}
+ }
- ///
- /// Gets the directory proxies for the directories inside the underlying one.
- ///
- /// The directory proxies for the directories inside the underlying one
- ///
- ///
- ///
- ///
- public async Task> GetDirectoryProxiesAsync()
+ ///
+ /// Gets the file proxies for the files inside the underlying one.
+ ///
+ /// The file proxies for the files inside the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetFileProxiesAsync()
+ {
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
{
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- {
- IList directoryProxies = new List();
+ IList fileProxies = new List();
- try
+ try
+ {
+ foreach (Metadata metadata in (await dropboxClient.Files.ListFolderAsync(this.path)).Entries.Where(m => m.IsFile))
{
- foreach (Metadata metadata in (await dropboxClient.Files.ListFolderAsync(this.path)).Entries.Where(m => m.IsFolder))
- directoryProxies.Add(new DirectoryProxy(this.accessToken, this.rootPath, metadata.PathDisplay.Substring(this.rootPath.Length)));
- }
+ string relativePath = metadata.PathDisplay;
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsPath)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
+ relativePath = relativePath.Substring(this.rootPath.Length);
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ if (relativePath.Contains("/"))
+ relativePath = relativePath.Remove(relativePath.LastIndexOf("/"));
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ fileProxies.Add(new FileProxy(this.accessToken, this.rootPath, relativePath, metadata.Name));
}
-
- return directoryProxies;
}
- }
- ///
- /// Gets the file proxies for the files inside the underlying one.
- ///
- /// The file proxies for the files inside the underlying directory.
- ///
- ///
- ///
- ///
- public async Task> GetFileProxiesAsync()
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ catch (ApiException e)
{
- IList fileProxies = new List();
-
- try
- {
- foreach (Metadata metadata in (await dropboxClient.Files.ListFolderAsync(this.path)).Entries.Where(m => m.IsFile))
- {
- string relativePath = metadata.PathDisplay;
-
- relativePath = relativePath.Substring(this.rootPath.Length);
-
- if (relativePath.Contains("/"))
- relativePath = relativePath.Remove(relativePath.LastIndexOf("/"));
-
- fileProxies.Add(new FileProxy(this.accessToken, this.rootPath, relativePath, metadata.Name));
- }
- }
-
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsPath)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
-
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ if (e.ErrorResponse.IsPath)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
- return fileProxies;
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
}
+
+ return fileProxies;
}
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Dropbox/ExtCore.FileStorage.Dropbox.csproj b/src/ExtCore.FileStorage.Dropbox/ExtCore.FileStorage.Dropbox.csproj
index ae86f92..46dcec9 100644
--- a/src/ExtCore.FileStorage.Dropbox/ExtCore.FileStorage.Dropbox.csproj
+++ b/src/ExtCore.FileStorage.Dropbox/ExtCore.FileStorage.Dropbox.csproj
@@ -1,20 +1,16 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 4.1.0
netstandard2.0
ExtCore.FileStorage.Dropbox
ExtCore.FileStorage.Dropbox
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
-
+
+
diff --git a/src/ExtCore.FileStorage.Dropbox/FileProxy.cs b/src/ExtCore.FileStorage.Dropbox/FileProxy.cs
index 2229210..e4fe2d1 100644
--- a/src/ExtCore.FileStorage.Dropbox/FileProxy.cs
+++ b/src/ExtCore.FileStorage.Dropbox/FileProxy.cs
@@ -10,268 +10,267 @@
using Dropbox.Api.Stone;
using ExtCore.FileStorage.Abstractions;
-namespace ExtCore.FileStorage.Dropbox
+namespace ExtCore.FileStorage.Dropbox;
+
+///
+/// Implements the IDirectoryProxy interface and represents a file in a Dropbox account.
+///
+public class FileProxy : IFileProxy
{
+ private readonly string accessToken;
+ private readonly string rootPath;
+ private readonly string filepath;
+
///
- /// Implements the IDirectoryProxy interface and represents a file in a Dropbox account.
+ /// The path of the underlying file relatively to the root one.
///
- public class FileProxy : IFileProxy
+ public string RelativePath { get; private set; }
+
+ ///
+ /// The filename of the underlying file.
+ ///
+ public string Filename { get; private set; }
+
+ ///
+ /// Initializes a new instance of the FileProxy class.
+ ///
+ /// The Dropbox's account access token.
+ /// The root path of the underlying file's relative one.
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ ///
+ ///
+ public FileProxy(string accessToken, string rootPath, string relativePath, string filename)
{
- private readonly string accessToken;
- private readonly string rootPath;
- private readonly string filepath;
-
- ///
- /// The path of the underlying file relatively to the root one.
- ///
- public string RelativePath { get; private set; }
-
- ///
- /// The filename of the underlying file.
- ///
- public string Filename { get; private set; }
-
- ///
- /// Initializes a new instance of the FileProxy class.
- ///
- /// The Dropbox's account access token.
- /// The root path of the underlying file's relative one.
- /// The path of the underlying file relatively to the root one.
- /// The filename of the underlying file.
- ///
- ///
- public FileProxy(string accessToken, string rootPath, string relativePath, string filename)
- {
- if (accessToken == string.Empty)
- throw new ArgumentException($"Value can't be empty. Parameter name: accessToken.");
+ if (accessToken == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: accessToken.");
- if (accessToken == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: accessToken.", default(Exception));
+ if (accessToken == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: accessToken.", default(Exception));
- if (filename == string.Empty)
- throw new ArgumentException($"Value can't be empty. Parameter name: filename.");
+ if (filename == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: filename.");
- if (filename == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: filename.", default(Exception));
+ if (filename == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: filename.", default(Exception));
- this.accessToken = accessToken;
- this.rootPath = rootPath;
- this.RelativePath = relativePath;
- this.Filename = filename;
- this.filepath = RelativeUrl.Combine(this.rootPath, this.RelativePath, this.Filename);
- }
+ this.accessToken = accessToken;
+ this.rootPath = RelativeUrl.Combine(rootPath);
+ this.RelativePath = RelativeUrl.Combine(relativePath);
+ this.Filename = filename;
+ this.filepath = RelativeUrl.Combine(this.rootPath, this.RelativePath, this.Filename);
+ }
- ///
- /// Checks if the underlying file exists.
- ///
- /// Returns a flag indicating if the underlying file exists.
- public async Task ExistsAsync()
+ ///
+ /// Checks if the underlying file exists.
+ ///
+ /// Returns a flag indicating if the underlying file exists.
+ public async Task ExistsAsync()
+ {
+ try
{
- try
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
{
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- {
- Metadata metadata = await dropboxClient.Files.GetMetadataAsync(this.filepath);
+ Metadata metadata = await dropboxClient.Files.GetMetadataAsync(this.filepath);
- return metadata.IsFile;
- }
+ return metadata.IsFile;
}
-
- catch { return false; }
}
- ///
- /// Reads content of the underlying file as a byte array.
- ///
- /// Content of the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadStreamAsync()
+ catch { return false; }
+ }
+
+ ///
+ /// Reads content of the underlying file as a byte array.
+ ///
+ /// Content of the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadStreamAsync()
+ {
+ try
{
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- using (IDownloadResponse response = await dropboxClient.Files.DownloadAsync(this.filepath))
- return await response.GetContentAsStreamAsync();
- }
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ using (IDownloadResponse response = await dropboxClient.Files.DownloadAsync(this.filepath))
+ return await response.GetContentAsStreamAsync();
+ }
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsPath)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ catch (ApiException e)
+ {
+ if (e.ErrorResponse.IsPath)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
+ }
- ///
- /// Reads content of the underlying file as a byte array.
- ///
- /// Content of the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadBytesAsync()
+ ///
+ /// Reads content of the underlying file as a byte array.
+ ///
+ /// Content of the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadBytesAsync()
+ {
+ try
{
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- using (IDownloadResponse response = await dropboxClient.Files.DownloadAsync(this.filepath))
- return await response.GetContentAsByteArrayAsync();
- }
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ using (IDownloadResponse response = await dropboxClient.Files.DownloadAsync(this.filepath))
+ return await response.GetContentAsByteArrayAsync();
+ }
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsPath)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ catch (ApiException e)
+ {
+ if (e.ErrorResponse.IsPath)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
+ }
- ///
- /// Reads content of the underlying file as a text string.
- ///
- /// Content of the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadTextAsync()
+ ///
+ /// Reads content of the underlying file as a text string.
+ ///
+ /// Content of the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadTextAsync()
+ {
+ try
{
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- using (IDownloadResponse response = await dropboxClient.Files.DownloadAsync(this.filepath))
- return await response.GetContentAsStringAsync();
- }
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ using (IDownloadResponse response = await dropboxClient.Files.DownloadAsync(this.filepath))
+ return await response.GetContentAsStringAsync();
+ }
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsPath)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ catch (ApiException e)
+ {
+ if (e.ErrorResponse.IsPath)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
+ }
- ///
- /// Writes content to the underlying file as a stream.
- ///
- /// Content to write to the underlying file as a stream.
- ///
- ///
- ///
- ///
- ///
- public async Task WriteStreamAsync(Stream inputStream)
+ ///
+ /// Writes content to the underlying file as a stream.
+ ///
+ /// Content to write to the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteStreamAsync(Stream inputStream)
+ {
+ try
{
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- await dropboxClient.Files.UploadAsync(this.filepath, WriteMode.Overwrite.Instance, body: inputStream);
- }
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ await dropboxClient.Files.UploadAsync(this.filepath, WriteMode.Overwrite.Instance, body: inputStream);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
+ }
- ///
- /// Writes content to the underlying file as a byte array.
- ///
- /// Content to write to the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- public async Task WriteBytesAsync(byte[] bytes)
+ ///
+ /// Writes content to the underlying file as a byte array.
+ ///
+ /// Content to write to the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteBytesAsync(byte[] bytes)
+ {
+ try
{
- try
- {
- using (MemoryStream inputStream = new MemoryStream(bytes))
- await this.WriteStreamAsync(inputStream);
- }
+ using (MemoryStream inputStream = new MemoryStream(bytes))
+ await this.WriteStreamAsync(inputStream);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
+ }
- ///
- /// Writes content to the underlying file as a text string.
- ///
- /// Content to write to the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- public async Task WriteTextAsync(string text)
+ ///
+ /// Writes content to the underlying file as a text string.
+ ///
+ /// Content to write to the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteTextAsync(string text)
+ {
+ try
{
- try
- {
- await this.WriteBytesAsync(Encoding.UTF8.GetBytes(text));
- }
+ await this.WriteBytesAsync(Encoding.UTF8.GetBytes(text));
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
+ }
- ///
- /// Deletes the underlying file.
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task DeleteAsync()
+ ///
+ /// Deletes the underlying file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync()
+ {
+ try
{
- try
- {
- using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
- await dropboxClient.Files.DeleteV2Async(this.filepath);
- }
+ using (DropboxClient dropboxClient = new DropboxClient(this.accessToken))
+ await dropboxClient.Files.DeleteV2Async(this.filepath);
+ }
- catch (ApiException e)
- {
- if (e.ErrorResponse.IsPath)
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ catch (ApiException e)
+ {
+ if (e.ErrorResponse.IsPath)
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
}
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Dropbox/FileStorage.cs b/src/ExtCore.FileStorage.Dropbox/FileStorage.cs
index 4df55ab..ab5f7a2 100644
--- a/src/ExtCore.FileStorage.Dropbox/FileStorage.cs
+++ b/src/ExtCore.FileStorage.Dropbox/FileStorage.cs
@@ -4,45 +4,44 @@
using ExtCore.FileStorage.Abstractions;
using Microsoft.Extensions.Options;
-namespace ExtCore.FileStorage.Dropbox
+namespace ExtCore.FileStorage.Dropbox;
+
+///
+/// Implements the IFileStorage interface and represents a file storage in a Dropbox account.
+///
+public class FileStorage : IFileStorage
{
+ private readonly string secret;
+ private readonly string rootPath;
+
///
- /// Implements the IFileStorage interface and represents a file storage in a Dropbox account.
+ /// Initializes a new instance of the FileStorage class.
///
- public class FileStorage : IFileStorage
+ /// The options that are used to configure the file storage root path.
+ public FileStorage(IOptions options)
{
- private readonly string secret;
- private readonly string rootPath;
-
- ///
- /// Initializes a new instance of the FileStorage class.
- ///
- /// The options that are used to configure the file storage root path.
- public FileStorage(IOptions options)
- {
- this.secret = options.Value.Secret;
- this.rootPath = options.Value.RootPath;
- }
+ this.secret = options.Value.Secret;
+ this.rootPath = options.Value.RootPath;
+ }
- ///
- /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
- ///
- /// The path of the underlying directory relatively to the root one.
- /// Created directory proxy.
- public IDirectoryProxy CreateDirectoryProxy(string relativePath)
- {
- return new DirectoryProxy(this.secret, this.rootPath, relativePath);
- }
+ ///
+ /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
+ ///
+ /// The path of the underlying directory relatively to the root one.
+ /// Created directory proxy.
+ public IDirectoryProxy CreateDirectoryProxy(string relativePath)
+ {
+ return new DirectoryProxy(this.secret, this.rootPath, relativePath);
+ }
- ///
- /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
- ///
- /// The path of the underlying file relatively to the root one.
- /// The filename of the underlying file.
- /// Created file proxy.
- public IFileProxy CreateFileProxy(string relativePath, string filename)
- {
- return new FileProxy(this.secret, this.rootPath, relativePath, filename);
- }
+ ///
+ /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
+ ///
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ /// Created file proxy.
+ public IFileProxy CreateFileProxy(string relativePath, string filename)
+ {
+ return new FileProxy(this.secret, this.rootPath, relativePath, filename);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Dropbox/RelativeUrl.cs b/src/ExtCore.FileStorage.Dropbox/RelativeUrl.cs
index 56303c1..298b9a0 100644
--- a/src/ExtCore.FileStorage.Dropbox/RelativeUrl.cs
+++ b/src/ExtCore.FileStorage.Dropbox/RelativeUrl.cs
@@ -4,18 +4,17 @@
using System;
using System.Linq;
-namespace ExtCore.FileStorage.Dropbox
+namespace ExtCore.FileStorage.Dropbox;
+
+public static class RelativeUrl
{
- public static class RelativeUrl
+ public static string Combine(params string[] segments)
{
- public static string Combine(params string[] segments)
- {
- return "/" + string.Join(
- "/",
- segments.Where(s => !string.IsNullOrEmpty(s)).Select(
- s => string.Join("/", s.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries))
- ).Where(s => !string.IsNullOrEmpty(s))
- );
- }
+ return "/" + string.Join(
+ "/",
+ segments.Where(s => !string.IsNullOrEmpty(s)).Select(
+ s => string.Join("/", s.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries))
+ ).Where(s => !string.IsNullOrEmpty(s))
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.Dropbox/icon.png b/src/ExtCore.FileStorage.Dropbox/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.FileStorage.Dropbox/icon.png differ
diff --git a/src/ExtCore.FileStorage.FileSystem/AbsolutePath.cs b/src/ExtCore.FileStorage.FileSystem/AbsolutePath.cs
index cab4a3b..1c27920 100644
--- a/src/ExtCore.FileStorage.FileSystem/AbsolutePath.cs
+++ b/src/ExtCore.FileStorage.FileSystem/AbsolutePath.cs
@@ -5,18 +5,17 @@
using System.IO;
using System.Linq;
-namespace ExtCore.FileStorage.FileSystem
+namespace ExtCore.FileStorage.FileSystem;
+
+public static class AbsolutePath
{
- public static class AbsolutePath
+ public static string Combine(params string[] segments)
{
- public static string Combine(params string[] segments)
- {
- return string.Join(
- Path.DirectorySeparatorChar.ToString(),
- segments.Where(s => !string.IsNullOrEmpty(s)).Select(
- s => string.Join(Path.DirectorySeparatorChar.ToString(), s.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries))
- ).Where(s => !string.IsNullOrEmpty(s))
- );
- }
+ return string.Join(
+ Path.DirectorySeparatorChar.ToString(),
+ segments.Where(s => !string.IsNullOrEmpty(s)).Select(
+ s => string.Join(Path.DirectorySeparatorChar.ToString(), s.Split(new char[] { '/', '\\' }, StringSplitOptions.RemoveEmptyEntries))
+ ).Where(s => !string.IsNullOrEmpty(s))
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.FileSystem/DirectoryProxy.cs b/src/ExtCore.FileStorage.FileSystem/DirectoryProxy.cs
index c135a8d..d7f1dce 100644
--- a/src/ExtCore.FileStorage.FileSystem/DirectoryProxy.cs
+++ b/src/ExtCore.FileStorage.FileSystem/DirectoryProxy.cs
@@ -8,103 +8,184 @@
using System.Threading.Tasks;
using ExtCore.FileStorage.Abstractions;
-namespace ExtCore.FileStorage.FileSystem
+namespace ExtCore.FileStorage.FileSystem;
+
+///
+/// Implements the IDirectoryProxy interface and represents a directory in a file system.
+///
+public class DirectoryProxy : IDirectoryProxy
{
+ private readonly string rootPath;
+ private readonly string path;
+
+ ///
+ /// The path of the underlying directory relatively to the root one.
+ ///
+ public string RelativePath { get; private set; }
+
///
- /// Implements the IDirectoryProxy interface and represents a directory in a file system.
+ /// Initializes a new instance of the DirectoryProxy class.
///
- public class DirectoryProxy : IDirectoryProxy
+ /// The root path of the underlying directory's relative one.
+ /// The path of the underlying directory relatively to the root one.
+ public DirectoryProxy(string rootPath, string relativePath)
{
- private readonly string rootPath;
- private readonly string path;
-
- ///
- /// The path of the underlying directory relatively to the root one.
- ///
- public string RelativePath { get; private set; }
-
- ///
- /// Initializes a new instance of the DirectoryProxy class.
- ///
- /// The root path of the underlying directory's relative one.
- /// The path of the underlying directory relatively to the root one.
- public DirectoryProxy(string rootPath, string relativePath)
- {
- this.rootPath = AbsolutePath.Combine(rootPath);
- this.RelativePath = AbsolutePath.Combine(relativePath);
- this.path = AbsolutePath.Combine(this.rootPath, this.RelativePath);
- }
-
- ///
- /// Checks if the underlying directory exists.
- ///
- /// Returns a flag indicating if the underlying directory exists.
- public async Task ExistsAsync()
+ this.rootPath = AbsolutePath.Combine(rootPath);
+ this.RelativePath = AbsolutePath.Combine(relativePath);
+ this.path = AbsolutePath.Combine(this.rootPath, this.RelativePath);
+ }
+
+ ///
+ /// Checks if the underlying directory exists.
+ ///
+ /// Returns a flag indicating if the underlying directory exists.
+ public async Task ExistsAsync()
+ {
+ return await Task.Factory.StartNew(() => Directory.Exists(this.path));
+ }
+
+ ///
+ /// Creates the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task CreateAsync()
+ {
+ await Task.Factory.StartNew(() =>
{
- return await Task.Factory.StartNew(() => Directory.Exists(this.path));
- }
-
- ///
- /// Creates the underlying directory.
- ///
- ///
- ///
- ///
- ///
- public async Task CreateAsync()
+ try
+ {
+ Directory.CreateDirectory(this.path);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.path}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.path}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Moves the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task MoveAsync(string destinationRelativePath)
+ {
+ if (destinationRelativePath == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: destinationRelativePath.");
+
+ if (destinationRelativePath == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: destinationRelativePath.", default(Exception));
+
+ await Task.Factory.StartNew(() =>
{
- await Task.Factory.StartNew(() =>
+ try
{
- try
- {
- Directory.CreateDirectory(this.path);
- }
+ Directory.Move(this.path, this.rootPath + destinationRelativePath);
+ }
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.path}\". See inner exception for details.", e);
- }
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.path}\". See inner exception for details.", e);
+ }
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
- }
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
+ }
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.path}\". See inner exception for details.", e);
- }
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.path}\". See inner exception for details.", e);
+ }
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Moves the underlying directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task MoveAsync(string destinationRelativePath)
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Deletes the underlying directory.
+ ///
+ /// Pass true to remove all the underlying directory content recursively; otherwise false.
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync(bool recursive)
+ {
+ await Task.Factory.StartNew(() =>
{
- if (destinationRelativePath == string.Empty)
- throw new ArgumentException($"Value can't be empty. Parameter name: destinationRelativePath.");
+ try
+ {
+ Directory.Delete(this.path, recursive);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.path}\". See inner exception for details.", e);
+ }
- if (destinationRelativePath == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: destinationRelativePath.", default(Exception));
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.path}\". See inner exception for details.", e);
+ }
- await Task.Factory.StartNew(() =>
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Gets the directory proxies for the directories inside the underlying one.
+ ///
+ /// The directory proxies for the directories inside the underlying one
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetDirectoryProxiesAsync()
+ {
+ return await Task>.Factory.StartNew(
+ () =>
{
try
{
- Directory.Move(this.path, this.rootPath + destinationRelativePath);
+ return Directory.GetDirectories(this.path).Select(
+ d => new DirectoryProxy(this.rootPath, d.Substring(this.rootPath.Length))
+ );
}
catch (UnauthorizedAccessException e)
@@ -126,24 +207,35 @@ await Task.Factory.StartNew(() =>
{
throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
}
- });
- }
-
- ///
- /// Deletes the underlying directory.
- ///
- /// Pass true to remove all the underlying directory content recursively; otherwise false.
- ///
- ///
- ///
- ///
- public async Task DeleteAsync(bool recursive)
- {
- await Task.Factory.StartNew(() =>
+ }
+ );
+ }
+
+ ///
+ /// Gets the file proxies for the files inside the underlying one.
+ ///
+ /// The file proxies for the files inside the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ public async Task> GetFileProxiesAsync()
+ {
+ return await Task>.Factory.StartNew(
+ () =>
{
try
{
- Directory.Delete(this.path, recursive);
+ return Directory.GetFiles(this.path).Select(
+ f =>
+ {
+ string relativePath = f;
+
+ relativePath = relativePath.Substring(this.rootPath.Length);
+ relativePath = relativePath.Remove(relativePath.LastIndexOf(Path.DirectorySeparatorChar));
+ return new FileProxy(this.rootPath, relativePath, f.Substring(f.LastIndexOf(Path.DirectorySeparatorChar) + 1));
+ }
+ );
}
catch (UnauthorizedAccessException e)
@@ -165,100 +257,7 @@ await Task.Factory.StartNew(() =>
{
throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
}
- });
- }
-
- ///
- /// Gets the directory proxies for the directories inside the underlying one.
- ///
- /// The directory proxies for the directories inside the underlying one
- ///
- ///
- ///
- ///
- public async Task> GetDirectoryProxiesAsync()
- {
- return await Task>.Factory.StartNew(
- () =>
- {
- try
- {
- return Directory.GetDirectories(this.path).Select(
- d => new DirectoryProxy(this.rootPath, d.Substring(this.rootPath.Length))
- );
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.path}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.path}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
- }
- );
- }
-
- ///
- /// Gets the file proxies for the files inside the underlying one.
- ///
- /// The file proxies for the files inside the underlying directory.
- ///
- ///
- ///
- ///
- public async Task> GetFileProxiesAsync()
- {
- return await Task>.Factory.StartNew(
- () =>
- {
- try
- {
- return Directory.GetFiles(this.path).Select(
- f =>
- {
- string relativePath = f;
-
- relativePath = relativePath.Substring(this.rootPath.Length);
- relativePath = relativePath.Remove(relativePath.LastIndexOf(Path.DirectorySeparatorChar));
- return new FileProxy(this.rootPath, relativePath, f.Substring(f.LastIndexOf(Path.DirectorySeparatorChar) + 1));
- }
- );
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.path}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.path}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.path}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
- }
- );
- }
+ }
+ );
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.FileSystem/ExtCore.FileStorage.FileSystem.csproj b/src/ExtCore.FileStorage.FileSystem/ExtCore.FileStorage.FileSystem.csproj
index 6657bf2..a5e0087 100644
--- a/src/ExtCore.FileStorage.FileSystem/ExtCore.FileStorage.FileSystem.csproj
+++ b/src/ExtCore.FileStorage.FileSystem/ExtCore.FileStorage.FileSystem.csproj
@@ -1,19 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 4.1.0
netstandard2.0
ExtCore.FileStorage.FileSystem
ExtCore.FileStorage.FileSystem
- http://extcore.net/extcore_nuget_icon.png
- http://extcore.net/
-
+
diff --git a/src/ExtCore.FileStorage.FileSystem/FileProxy.cs b/src/ExtCore.FileStorage.FileSystem/FileProxy.cs
index e86ac18..1a44a5d 100644
--- a/src/ExtCore.FileStorage.FileSystem/FileProxy.cs
+++ b/src/ExtCore.FileStorage.FileSystem/FileProxy.cs
@@ -7,382 +7,381 @@
using System.Threading.Tasks;
using ExtCore.FileStorage.Abstractions;
-namespace ExtCore.FileStorage.FileSystem
+namespace ExtCore.FileStorage.FileSystem;
+
+///
+/// Implements the IDirectoryProxy interface and represents a file in a file system.
+///
+public class FileProxy : IFileProxy
{
+ private readonly string rootPath;
+ private readonly string filepath;
+
+ ///
+ /// The path of the underlying file relatively to the root one.
+ ///
+ public string RelativePath { get; private set; }
+
///
- /// Implements the IDirectoryProxy interface and represents a file in a file system.
+ /// The filename of the underlying file.
///
- public class FileProxy : IFileProxy
+ public string Filename { get; private set; }
+
+ ///
+ /// Initializes a new instance of the FileProxy class.
+ ///
+ /// The root path of the underlying file's relative one.
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ ///
+ ///
+ public FileProxy(string rootPath, string relativePath, string filename)
{
- private readonly string rootPath;
- private readonly string filepath;
-
- ///
- /// The path of the underlying file relatively to the root one.
- ///
- public string RelativePath { get; private set; }
-
- ///
- /// The filename of the underlying file.
- ///
- public string Filename { get; private set; }
-
- ///
- /// Initializes a new instance of the FileProxy class.
- ///
- /// The root path of the underlying file's relative one.
- /// The path of the underlying file relatively to the root one.
- /// The filename of the underlying file.
- ///
- ///
- public FileProxy(string rootPath, string relativePath, string filename)
- {
- if (filename == string.Empty)
- throw new ArgumentException($"Value can't be empty. Parameter name: filename.");
-
- if (filename == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: filename.", default(Exception));
-
- this.rootPath = rootPath;
- this.RelativePath = relativePath;
- this.Filename = filename;
- this.filepath = AbsolutePath.Combine(this.rootPath, this.RelativePath, this.Filename);
- }
-
- ///
- /// Checks if the underlying file exists.
- ///
- /// Returns a flag indicating if the underlying file exists.
- public async Task ExistsAsync()
- {
- return await Task.Factory.StartNew(() => File.Exists(this.filepath));
- }
-
- ///
- /// Reads content of the underlying file as a stream.
- ///
- /// Content of the underlying file as a stream.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadStreamAsync()
+ if (filename == string.Empty)
+ throw new ArgumentException($"Value can't be empty. Parameter name: filename.");
+
+ if (filename == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: filename.", default(Exception));
+
+ this.rootPath = rootPath;
+ this.RelativePath = relativePath;
+ this.Filename = filename;
+ this.filepath = AbsolutePath.Combine(this.rootPath, this.RelativePath, this.Filename);
+ }
+
+ ///
+ /// Checks if the underlying file exists.
+ ///
+ /// Returns a flag indicating if the underlying file exists.
+ public async Task ExistsAsync()
+ {
+ return await Task.Factory.StartNew(() => File.Exists(this.filepath));
+ }
+
+ ///
+ /// Reads content of the underlying file as a stream.
+ ///
+ /// Content of the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadStreamAsync()
+ {
+ return await Task.Factory.StartNew(() =>
{
- return await Task.Factory.StartNew(() =>
- {
- try
- {
- return File.Open(this.filepath, FileMode.Open);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.FileNotFoundException e)
- {
- throw new FileNotFoundException($"File not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Reads content of the underlying file as a byte array.
- ///
- /// Content of the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadBytesAsync()
+ try
+ {
+ return File.Open(this.filepath, FileMode.Open);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.FileNotFoundException e)
+ {
+ throw new FileNotFoundException($"File not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Reads content of the underlying file as a byte array.
+ ///
+ /// Content of the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadBytesAsync()
+ {
+ return await Task.Factory.StartNew(() =>
{
- return await Task.Factory.StartNew(() =>
- {
- try
- {
- return File.ReadAllBytes(this.filepath);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (SecurityException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.FileNotFoundException e)
- {
- throw new FileNotFoundException($"File not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Reads content of the underlying file as a text string.
- ///
- /// Content of the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadTextAsync()
+ try
+ {
+ return File.ReadAllBytes(this.filepath);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (SecurityException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.FileNotFoundException e)
+ {
+ throw new FileNotFoundException($"File not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Reads content of the underlying file as a text string.
+ ///
+ /// Content of the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task ReadTextAsync()
+ {
+ return await Task.Factory.StartNew(() =>
{
- return await Task.Factory.StartNew(() =>
- {
- try
- {
- return File.ReadAllText(this.filepath);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (SecurityException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.FileNotFoundException e)
- {
- throw new FileNotFoundException($"File not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Writes content to the underlying file as a stream.
- ///
- /// Content to write to the underlying file as a stream.
- ///
- ///
- ///
- ///
- ///
- public async Task WriteStreamAsync(Stream inputStream)
+ try
+ {
+ return File.ReadAllText(this.filepath);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (SecurityException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.FileNotFoundException e)
+ {
+ throw new FileNotFoundException($"File not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Writes content to the underlying file as a stream.
+ ///
+ /// Content to write to the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteStreamAsync(Stream inputStream)
+ {
+ if (inputStream == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: inputStream.", default(Exception));
+
+ await Task.Factory.StartNew(() =>
{
- if (inputStream == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: inputStream.", default(Exception));
-
- await Task.Factory.StartNew(() =>
- {
- try
- {
- using (Stream outputStream = File.Create(this.filepath))
- inputStream.CopyTo(outputStream);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Writes content to the underlying file as a byte array.
- ///
- /// Content to write to the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- public async Task WriteBytesAsync(byte[] bytes)
+ try
+ {
+ using (Stream outputStream = File.Create(this.filepath))
+ inputStream.CopyTo(outputStream);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Writes content to the underlying file as a byte array.
+ ///
+ /// Content to write to the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteBytesAsync(byte[] bytes)
+ {
+ if (bytes == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: bytes.", default(Exception));
+
+ await Task.Factory.StartNew(() =>
{
- if (bytes == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: bytes.", default(Exception));
-
- await Task.Factory.StartNew(() =>
- {
- try
- {
- File.WriteAllBytes(this.filepath, bytes);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (SecurityException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Writes content to the underlying file as a text string.
- ///
- /// Content to write to the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- public async Task WriteTextAsync(string text)
+ try
+ {
+ File.WriteAllBytes(this.filepath, bytes);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (SecurityException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Writes content to the underlying file as a text string.
+ ///
+ /// Content to write to the underlying file as a text string.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteTextAsync(string text)
+ {
+ if (text == null)
+ throw new ArgumentNullException($"Value can't be null. Parameter name: text.", default(Exception));
+
+ await Task.Factory.StartNew(() =>
{
- if (text == null)
- throw new ArgumentNullException($"Value can't be null. Parameter name: text.", default(Exception));
-
- await Task.Factory.StartNew(() =>
- {
- try
- {
- File.WriteAllText(this.filepath, text);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (SecurityException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
-
- ///
- /// Deletes the underlying file.
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task DeleteAsync()
+ try
+ {
+ File.WriteAllText(this.filepath, text);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (SecurityException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
+ }
+
+ ///
+ /// Deletes the underlying file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync()
+ {
+ await Task.Factory.StartNew(() =>
{
- await Task.Factory.StartNew(() =>
- {
- if (!File.Exists(this.filepath))
- throw new FileNotFoundException($"File not found: \"{this.filepath}\".", null);
-
- try
- {
- File.Delete(this.filepath);
- }
-
- catch (UnauthorizedAccessException e)
- {
- throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.DirectoryNotFoundException e)
- {
- throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (System.IO.PathTooLongException e)
- {
- throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
- }
-
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
- }
- });
- }
+ if (!File.Exists(this.filepath))
+ throw new FileNotFoundException($"File not found: \"{this.filepath}\".", null);
+
+ try
+ {
+ File.Delete(this.filepath);
+ }
+
+ catch (UnauthorizedAccessException e)
+ {
+ throw new AccessDeniedException($"Access denied: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.DirectoryNotFoundException e)
+ {
+ throw new DirectoryNotFoundException($"Directory not found: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (System.IO.PathTooLongException e)
+ {
+ throw new PathTooLongException($"Path too long: \"{this.filepath}\". See inner exception for details.", e);
+ }
+
+ catch (Exception e)
+ {
+ throw new FileStorageException($"Generic file storage exception: \"{this.filepath}\". See inner exception for details.", e);
+ }
+ });
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.FileSystem/FileStorage.cs b/src/ExtCore.FileStorage.FileSystem/FileStorage.cs
index 72692f4..2d308f6 100644
--- a/src/ExtCore.FileStorage.FileSystem/FileStorage.cs
+++ b/src/ExtCore.FileStorage.FileSystem/FileStorage.cs
@@ -4,43 +4,42 @@
using ExtCore.FileStorage.Abstractions;
using Microsoft.Extensions.Options;
-namespace ExtCore.FileStorage.FileSystem
+namespace ExtCore.FileStorage.FileSystem;
+
+///
+/// Implements the IFileStorage interface and represents a file storage in a file system.
+///
+public class FileStorage : IFileStorage
{
+ private readonly string rootPath;
+
///
- /// Implements the IFileStorage interface and represents a file storage in a file system.
+ /// Initializes a new instance of the FileStorage class.
///
- public class FileStorage : IFileStorage
+ /// The options that are used to configure the file storage root path.
+ public FileStorage(IOptions options)
{
- private readonly string rootPath;
-
- ///
- /// Initializes a new instance of the FileStorage class.
- ///
- /// The options that are used to configure the file storage root path.
- public FileStorage(IOptions options)
- {
- this.rootPath = options.Value.RootPath;
- }
+ this.rootPath = options.Value.RootPath;
+ }
- ///
- /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
- ///
- /// The path of the underlying directory relatively to the root one.
- /// Created directory proxy.
- public IDirectoryProxy CreateDirectoryProxy(string relativePath)
- {
- return new DirectoryProxy(this.rootPath, relativePath);
- }
+ ///
+ /// Creates a directory proxy which allows to manipulate an underlying directory with a specified relative path.
+ ///
+ /// The path of the underlying directory relatively to the root one.
+ /// Created directory proxy.
+ public IDirectoryProxy CreateDirectoryProxy(string relativePath)
+ {
+ return new DirectoryProxy(this.rootPath, relativePath);
+ }
- ///
- /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
- ///
- /// The path of the underlying file relatively to the root one.
- /// The filename of the underlying file.
- /// Created file proxy.
- public IFileProxy CreateFileProxy(string relativePath, string filename)
- {
- return new FileProxy(this.rootPath, relativePath, filename);
- }
+ ///
+ /// Creates a file proxy which allows to manipulate an underlying file with a specified relative path and a filename.
+ ///
+ /// The path of the underlying file relatively to the root one.
+ /// The filename of the underlying file.
+ /// Created file proxy.
+ public IFileProxy CreateFileProxy(string relativePath, string filename)
+ {
+ return new FileProxy(this.rootPath, relativePath, filename);
}
}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage.FileSystem/icon.png b/src/ExtCore.FileStorage.FileSystem/icon.png
new file mode 100644
index 0000000..658aadf
Binary files /dev/null and b/src/ExtCore.FileStorage.FileSystem/icon.png differ
diff --git a/src/ExtCore.FileStorage/Actions/AddDirectoryProxyAction.cs b/src/ExtCore.FileStorage/Actions/AddDirectoryProxyAction.cs
deleted file mode 100644
index c7c388e..0000000
--- a/src/ExtCore.FileStorage/Actions/AddDirectoryProxyAction.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using System.Reflection;
-using ExtCore.FileStorage.Abstractions;
-using ExtCore.Infrastructure;
-using ExtCore.Infrastructure.Actions;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-
-namespace ExtCore.FileStorage.Actions
-{
- ///
- /// Implements the IConfigureServicesAction interface and
- /// registers found implementation of the IDirectoryProxy interface inside the DI.
- ///
- public class AddDirectoryProxyAction : IConfigureServicesAction
- {
- ///
- /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
- ///
- public int Priority => 1000;
-
- ///
- /// Registers found implementation of the IDirectoryProxy interface inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to register any service inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
- ///
- public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
- {
- Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
-
- if (type == null)
- {
- ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.FileStorage");
-
- logger.LogError("Implementation of ExtCore.FileStorage.Abstractions.IDirectoryProxy not found");
- return;
- }
-
- services.AddScoped(typeof(IDirectoryProxy), type);
- }
- }
-}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage/Actions/AddFileProxyAction.cs b/src/ExtCore.FileStorage/Actions/AddFileProxyAction.cs
deleted file mode 100644
index b84e783..0000000
--- a/src/ExtCore.FileStorage/Actions/AddFileProxyAction.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Linq;
-using System.Reflection;
-using ExtCore.FileStorage.Abstractions;
-using ExtCore.Infrastructure;
-using ExtCore.Infrastructure.Actions;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-
-namespace ExtCore.FileStorage.Actions
-{
- ///
- /// Implements the IConfigureServicesAction interface and
- /// registers found implementation of the IFileProxy interface inside the DI.
- ///
- public class AddFileProxyAction : IConfigureServicesAction
- {
- ///
- /// Priority of the action. The actions will be executed in the order specified by the priority (from smallest to largest).
- ///
- public int Priority => 1000;
-
- ///
- /// Registers found implementation of the IFileProxy interface inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to register any service inside the DI.
- ///
- ///
- /// Will be provided by the ExtCore and might be used to get any service that is registered inside the DI at this moment.
- ///
- public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
- {
- Type type = ExtensionManager.GetImplementations()?.FirstOrDefault(t => !t.GetTypeInfo().IsAbstract);
-
- if (type == null)
- {
- ILogger logger = serviceProvider.GetService().CreateLogger("ExtCore.FileStorage");
-
- logger.LogError("Implementation of ExtCore.FileStorage.Abstractions.IFileProxy not found");
- return;
- }
-
- services.AddScoped(typeof(IFileProxy), type);
- }
- }
-}
\ No newline at end of file
diff --git a/src/ExtCore.FileStorage/Actions/AddFileStorageAction.cs b/src/ExtCore.FileStorage/Actions/AddFileStorageAction.cs
index 89402ae..2debc52 100644
--- a/src/ExtCore.FileStorage/Actions/AddFileStorageAction.cs
+++ b/src/ExtCore.FileStorage/Actions/AddFileStorageAction.cs
@@ -10,41 +10,40 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-namespace ExtCore.FileStorage.Actions
+namespace ExtCore.FileStorage.Actions;
+
+///
+/// Implements the