diff --git a/README.md b/README.md
index 3835991..6588949 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# ExtCore 7.1.3
+# ExtCore 9.0.0
[](https://gitter.im/ExtCore/ExtCore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -93,20 +93,20 @@ in order to execute some code inside the ConfigureServices and Configure methods
Please take a look at our samples on GitHub:
-* [Full-featured ExtCore 7.0.0 framework sample web application](https://github.com/ExtCore/ExtCore-Sample);
-* [ExtCore framework 7.0.0 sample simplest web application](https://github.com/ExtCore/ExtCore-Sample-Simplest);
-* [ExtCore framework 7.0.0 sample MVC web application](https://github.com/ExtCore/ExtCore-Sample-Mvc);
-* [ExtCore framework 7.0.0 sample web application that uses file storage](https://github.com/ExtCore/ExtCore-Sample-FileStorage);
-* [ExtCore framework 7.0.0 sample web application that uses a database](https://github.com/ExtCore/ExtCore-Sample-Data);
-* [ExtCore framework 7.0.0 sample web application that uses Identity](https://github.com/ExtCore/ExtCore-Sample-Identity);
-* [ExtCore framework 7.0.0 sample web application with modular UI](https://github.com/ExtCore/ExtCore-Sample-Modular-Ui);
-* [ExtCore framework 7.0.0 advanced sample web application with modular UI](https://github.com/ExtCore/ExtCore-Sample-Modular-Ui-Adv);
-* [ExtCore framework 7.0.0 advanced sample accounting web application](https://github.com/ExtCore/ExtCore-Sample-Accounting);
-* [ExtCore framework 7.0.0 sample web application that registers a service inside the extension](https://github.com/ExtCore/ExtCore-Sample-Service);
-* [ExtCore framework 7.0.0 sample web application that uses the events](https://github.com/ExtCore/ExtCore-Sample-Events);
-* [ExtCore framework 7.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-7.0.0.zip).
+* [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.
diff --git a/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj b/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj
index 60010e6..186297d 100644
--- a/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj
+++ b/src/ExtCore.Data.Abstractions/ExtCore.Data.Abstractions.csproj
@@ -1,20 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data extension component. Based on the ExtCore framework.
- 7.1.3
netstandard2.0
ExtCore.Data.Abstractions
ExtCore.Data.Abstractions
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
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.Dapper.MySql/ExtCore.Data.Dapper.MySql.csproj b/src/ExtCore.Data.Dapper.MySql/ExtCore.Data.Dapper.MySql.csproj
index 1f24fcd..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.Dapper.MySql
ExtCore.Data.Dapper.MySql
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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.PostgreSql/ExtCore.Data.Dapper.PostgreSql.csproj b/src/ExtCore.Data.Dapper.PostgreSql/ExtCore.Data.Dapper.PostgreSql.csproj
index 5a423fd..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.Dapper.PostgreSql
ExtCore.Data.Dapper.PostgreSql
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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.SqlServer/ExtCore.Data.Dapper.SqlServer.csproj b/src/ExtCore.Data.Dapper.SqlServer/ExtCore.Data.Dapper.SqlServer.csproj
index 4f8c1cc..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,22 +1,13 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.Dapper.SqlServer
ExtCore.Data.Dapper.SqlServer
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
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.Sqlite/ExtCore.Data.Dapper.Sqlite.csproj b/src/ExtCore.Data.Dapper.Sqlite/ExtCore.Data.Dapper.Sqlite.csproj
index 7e62b54..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.Dapper.Sqlite
ExtCore.Data.Dapper.Sqlite
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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/Actions/AddStorageContextAction.cs b/src/ExtCore.Data.Dapper/Actions/AddStorageContextAction.cs
index e1c6771..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 e6f1038..367721d 100644
--- a/src/ExtCore.Data.Dapper/ExtCore.Data.Dapper.csproj
+++ b/src/ExtCore.Data.Dapper/ExtCore.Data.Dapper.csproj
@@ -1,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.Dapper extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.Dapper
ExtCore.Data.Dapper
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
diff --git a/src/ExtCore.Data.Dapper/Extension.cs b/src/ExtCore.Data.Dapper/Extension.cs
index 5d1c1f4..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 => "https://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 => "7.1.3";
+ ///
+ /// 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.Entities.Abstractions/ExtCore.Data.Entities.Abstractions.csproj b/src/ExtCore.Data.Entities.Abstractions/ExtCore.Data.Entities.Abstractions.csproj
index 2c8eb1c..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,20 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data extension component. Based on the ExtCore framework.
- 7.1.3
netstandard2.0
ExtCore.Data.Entities.Abstractions
ExtCore.Data.Entities.Abstractions
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
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.EntityFramework.MySql/ExtCore.Data.EntityFramework.MySql.csproj b/src/ExtCore.Data.EntityFramework.MySql/ExtCore.Data.EntityFramework.MySql.csproj
index c817e2a..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.EntityFramework.MySql
ExtCore.Data.EntityFramework.MySql
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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.PostgreSql/ExtCore.Data.EntityFramework.PostgreSql.csproj b/src/ExtCore.Data.EntityFramework.PostgreSql/ExtCore.Data.EntityFramework.PostgreSql.csproj
index 40b1c44..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.EntityFramework.PostgreSql
ExtCore.Data.EntityFramework.PostgreSql
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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.SqlServer/ExtCore.Data.EntityFramework.SqlServer.csproj b/src/ExtCore.Data.EntityFramework.SqlServer/ExtCore.Data.EntityFramework.SqlServer.csproj
index 0bf3bd3..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.EntityFramework.SqlServer
ExtCore.Data.EntityFramework.SqlServer
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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.Sqlite/ExtCore.Data.EntityFramework.Sqlite.csproj b/src/ExtCore.Data.EntityFramework.Sqlite/ExtCore.Data.EntityFramework.Sqlite.csproj
index 4f5d828..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,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.EntityFramework.Sqlite
ExtCore.Data.EntityFramework.Sqlite
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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/Actions/AddStorageContextAction.cs b/src/ExtCore.Data.EntityFramework/Actions/AddStorageContextAction.cs
index 8b0b45c..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 da7108b..40f1857 100644
--- a/src/ExtCore.Data.EntityFramework/ExtCore.Data.EntityFramework.csproj
+++ b/src/ExtCore.Data.EntityFramework/ExtCore.Data.EntityFramework.csproj
@@ -1,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Data.EntityFramework extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data.EntityFramework
ExtCore.Data.EntityFramework
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
diff --git a/src/ExtCore.Data.EntityFramework/Extension.cs b/src/ExtCore.Data.EntityFramework/Extension.cs
index b5a0e8c..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 => "https://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 => "7.1.3";
+ ///
+ /// 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/Actions/AddStorageAction.cs b/src/ExtCore.Data/Actions/AddStorageAction.cs
index 9989b63..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 ff1350a..dcd0e80 100644
--- a/src/ExtCore.Data/ExtCore.Data.csproj
+++ b/src/ExtCore.Data/ExtCore.Data.csproj
@@ -1,22 +1,13 @@
+
- Dmitry Sikorsky
- Copyright © 2015 Dmitry Sikorsky
The ExtCore.Data extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Data
ExtCore.Data
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
diff --git a/src/ExtCore.Data/Extension.cs b/src/ExtCore.Data/Extension.cs
index 054321b..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 => "https://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 => "7.1.3";
+ ///
+ /// 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/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 76ed103..6a91583 100644
--- a/src/ExtCore.Events/ExtCore.Events.csproj
+++ b/src/ExtCore.Events/ExtCore.Events.csproj
@@ -1,22 +1,13 @@
+
- Dmitry Sikorsky
- Copyright © 2017 Dmitry Sikorsky
The ExtCore.Events extension component. Based on the ExtCore framework.
- 7.1.3
- net6.0
+ net8.0
ExtCore.Events
ExtCore.Events
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
diff --git a/src/ExtCore.Events/Extension.cs b/src/ExtCore.Events/Extension.cs
index 37f04b9..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 => "https://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 => "7.1.3";
+ ///
+ /// 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.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 dd48ed9..84dc73d 100644
--- a/src/ExtCore.FileStorage.Abstractions/ExtCore.FileStorage.Abstractions.csproj
+++ b/src/ExtCore.FileStorage.Abstractions/ExtCore.FileStorage.Abstractions.csproj
@@ -1,20 +1,11 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 7.1.3
netstandard2.0
ExtCore.FileStorage.Abstractions
ExtCore.FileStorage.Abstractions
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
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.Azure/DirectoryProxy.cs b/src/ExtCore.FileStorage.Azure/DirectoryProxy.cs
index 6e0be3d..d6b474b 100644
--- a/src/ExtCore.FileStorage.Azure/DirectoryProxy.cs
+++ b/src/ExtCore.FileStorage.Azure/DirectoryProxy.cs
@@ -10,216 +10,215 @@
using Azure.Storage.Blobs.Models;
using ExtCore.FileStorage.Abstractions;
-namespace ExtCore.FileStorage.Azure
+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; }
+
///
- /// Implements the IDirectoryProxy interface and represents a directory in a Azure Storage account.
+ /// Initializes a new instance of the DirectoryProxy class.
///
- public class DirectoryProxy : IDirectoryProxy
+ /// 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)
{
- 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 == 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 (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);
+ 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('/');
+ string[] urlSegments = path.Split('/');
- this.containerName = urlSegments.First();
- this.prefix = string.Join("/", urlSegments.Skip(1));
- }
+ 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()
+ ///
+ /// Checks if the underlying directory exists.
+ ///
+ /// Returns a flag indicating if the underlying directory exists.
+ public async Task ExistsAsync()
+ {
+ try
{
- try
- {
- BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
- IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: this.prefix).AsPages();
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+ IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: this.prefix).AsPages();
- await foreach (Page page in pages)
- return page.Values.Count != 0;
- }
+ await foreach (Page page in pages)
+ return page.Values.Count != 0;
+ }
- catch { }
+ catch { }
- return false;
- }
+ return false;
+ }
- ///
- /// Creates the underlying directory.
- ///
- ///
- ///
- ///
- ///
- public async Task CreateAsync()
- {
- throw new NotSupportedException();
- }
+ ///
+ /// Creates the underlying directory.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task CreateAsync()
+ {
+ throw new NotSupportedException();
+ }
- ///
- /// Moves the underlying directory.
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public async Task MoveAsync(string destinationRelativePath)
- {
- 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)
+ ///
+ /// Deletes the underlying directory.
+ ///
+ /// Pass true to remove all the underlying directory content recursively; otherwise false.
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync(bool recursive)
+ {
+ try
{
- try
- {
- BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+ BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
- if (string.IsNullOrEmpty(this.prefix))
- {
- await blobContainerClient.DeleteAsync();
- return;
- }
+ if (string.IsNullOrEmpty(this.prefix))
+ {
+ await blobContainerClient.DeleteAsync();
+ return;
+ }
- string prefix = this.prefix + "/";
- IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: recursive ? null : "/").AsPages();
+ string prefix = this.prefix + "/";
+ IAsyncEnumerable> pages = blobContainerClient.GetBlobsByHierarchyAsync(prefix: prefix, delimiter: recursive ? null : "/").AsPages();
- await foreach (Page page in pages)
+ await foreach (Page page in pages)
+ {
+ foreach (BlobHierarchyItem blobItem in page.Values)
{
- foreach (BlobHierarchyItem blobItem in page.Values)
+ if (blobItem.IsBlob)
{
- if (blobItem.IsBlob)
- {
- BlobClient blobClient = await this.GetBlobClient(blobItem.Blob);
+ BlobClient blobClient = await this.GetBlobClient(blobItem.Blob);
- await blobClient.DeleteAsync();
- }
+ 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()
+ catch (Exception e)
{
- 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();
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
- 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())));
+ ///
+ /// 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();
- return directoryProxies;
- }
+ 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())));
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ 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()
+ catch (Exception e)
{
- 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();
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
+ }
+ }
- 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()));
+ ///
+ /// 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();
- return fileProxies;
- }
+ 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()));
- catch (Exception e)
- {
- throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
- }
+ return fileProxies;
}
- private BlobContainerClient GetBlobContainerClient()
+ catch (Exception e)
{
- BlobServiceClient blobServiceClient = new BlobServiceClient(this.connectionString);
-
- return blobServiceClient.GetBlobContainerClient(this.containerName);
+ throw new FileStorageException($"Generic file storage exception: \"{this.path}\". See inner exception for details.", e);
}
+ }
- private async Task GetBlobClient(BlobItem blobItem)
- {
- BlobContainerClient blobContainerClient = this.GetBlobContainerClient();
+ private BlobContainerClient GetBlobContainerClient()
+ {
+ BlobServiceClient blobServiceClient = new BlobServiceClient(this.connectionString);
- await blobContainerClient.CreateIfNotExistsAsync();
- return blobContainerClient.GetBlobClient(blobItem.Name);
- }
+ 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
index 0dca7f2..07eb781 100644
--- a/src/ExtCore.FileStorage.Azure/ExtCore.FileStorage.Azure.csproj
+++ b/src/ExtCore.FileStorage.Azure/ExtCore.FileStorage.Azure.csproj
@@ -1,27 +1,17 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 7.1.3
netstandard2.0
- 8.0
ExtCore.FileStorage.Azure
ExtCore.FileStorage.Azure
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
-
-
+
+
+
diff --git a/src/ExtCore.FileStorage.Azure/FileProxy.cs b/src/ExtCore.FileStorage.Azure/FileProxy.cs
index b95a2ba..9fced27 100644
--- a/src/ExtCore.FileStorage.Azure/FileProxy.cs
+++ b/src/ExtCore.FileStorage.Azure/FileProxy.cs
@@ -9,260 +9,259 @@
using Azure.Storage.Blobs.Models;
using ExtCore.FileStorage.Abstractions;
-namespace ExtCore.FileStorage.Azure
+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; }
+
///
- /// Implements the IDirectoryProxy interface and represents a file in a Azure Storage account.
+ /// Initializes a new instance of the FileProxy class.
///
- public class FileProxy : IFileProxy
+ /// 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)
{
- 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 == 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 (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 == 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.connectionString = connectionString;
+ this.RelativePath = RelativeUrl.Combine(relativePath);
+ this.Filename = filename;
+ this.filepath = RelativeUrl.Combine(rootPath, this.RelativePath, this.Filename);
- 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));
+ }
- string[] urlSegments = filepath.Split('/');
+ ///
+ /// 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();
- this.containerName = urlSegments.First();
- this.blobName = string.Join("/", urlSegments.Skip(1));
+ return await blobClient.ExistsAsync();
}
- ///
- /// Checks if the underlying file exists.
- ///
- /// Returns a flag indicating if the underlying file exists.
- public async Task ExistsAsync()
+ catch
{
- try
- {
- BlobClient blobClient = await this.GetBlobClient();
+ return false;
+ }
+ }
- return await blobClient.ExistsAsync();
- }
+ ///
+ /// 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();
- catch
- {
- return false;
- }
+ await blobClient.DownloadToAsync(stream);
+ stream.Position = 0;
+ return stream;
}
- ///
- /// Reads content of the underlying file as a byte array.
- ///
- /// Content of the underlying file as a byte array.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadStreamAsync()
+ catch (Exception e)
{
- 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);
- }
+ 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
- {
- 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);
- }
+ BlobClient blobClient = await this.GetBlobClient();
+ BlobDownloadResult downloadResult = await blobClient.DownloadContentAsync();
+
+ return downloadResult.Content.ToArray();
}
- ///
- /// Reads content of the underlying file as a text string.
- ///
- /// Content of the underlying file as a text string.
- ///
- ///
- ///
- ///
- ///
- public async Task ReadTextAsync()
+ catch (Exception e)
{
- 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);
- }
+ 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)
+ ///
+ /// 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
- {
- BlobClient blobClient = await this.GetBlobClient();
+ BlobClient blobClient = await this.GetBlobClient();
+ BlobDownloadResult downloadResult = await blobClient.DownloadContentAsync();
- await blobClient.UploadAsync(inputStream);
- }
+ return downloadResult.Content.ToString();
+ }
- 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 stream.
+ ///
+ /// Content to write to the underlying file as a stream.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteStreamAsync(Stream inputStream)
+ {
+ try
{
- try
- {
- BlobClient blobClient = await this.GetBlobClient();
+ BlobClient blobClient = await this.GetBlobClient();
- await blobClient.UploadAsync(BinaryData.FromBytes(bytes));
- }
+ await blobClient.UploadAsync(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 byte array.
+ ///
+ /// Content to write to the underlying file as a byte array.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task WriteBytesAsync(byte[] bytes)
+ {
+ try
{
- try
- {
- BlobClient blobClient = await this.GetBlobClient();
+ BlobClient blobClient = await this.GetBlobClient();
- await blobClient.UploadAsync(BinaryData.FromString(text));
- }
+ await blobClient.UploadAsync(BinaryData.FromBytes(bytes));
+ }
- 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()
+ ///
+ /// 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
- {
- BlobClient blobClient = await this.GetBlobClient();
+ BlobClient blobClient = await this.GetBlobClient();
- await blobClient.DeleteAsync();
- }
+ await blobClient.UploadAsync(BinaryData.FromString(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);
}
+ }
- private async Task GetBlobClient()
+ ///
+ /// Deletes the underlying file.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task DeleteAsync()
+ {
+ try
{
- BlobServiceClient blobServiceClient = new BlobServiceClient(this.connectionString);
- BlobContainerClient blobContainerClient = blobServiceClient.GetBlobContainerClient(this.containerName);
+ BlobClient blobClient = await this.GetBlobClient();
- await blobContainerClient.CreateIfNotExistsAsync();
- return blobContainerClient.GetBlobClient(this.blobName);
+ 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
index 71868e1..b5a9b2b 100644
--- a/src/ExtCore.FileStorage.Azure/FileStorage.cs
+++ b/src/ExtCore.FileStorage.Azure/FileStorage.cs
@@ -4,45 +4,44 @@
using ExtCore.FileStorage.Abstractions;
using Microsoft.Extensions.Options;
-namespace ExtCore.FileStorage.Azure
+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;
+
///
- /// Implements the IFileStorage interface and represents a file storage in a Azure Storage 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.Azure/RelativeUrl.cs b/src/ExtCore.FileStorage.Azure/RelativeUrl.cs
index b220ecf..539139f 100644
--- a/src/ExtCore.FileStorage.Azure/RelativeUrl.cs
+++ b/src/ExtCore.FileStorage.Azure/RelativeUrl.cs
@@ -4,18 +4,17 @@
using System;
using System.Linq;
-namespace ExtCore.FileStorage.Azure
+namespace ExtCore.FileStorage.Azure;
+
+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/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 09c0e44..46dcec9 100644
--- a/src/ExtCore.FileStorage.Dropbox/ExtCore.FileStorage.Dropbox.csproj
+++ b/src/ExtCore.FileStorage.Dropbox/ExtCore.FileStorage.Dropbox.csproj
@@ -1,25 +1,16 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 7.1.3
netstandard2.0
ExtCore.FileStorage.Dropbox
ExtCore.FileStorage.Dropbox
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
-
+
+
diff --git a/src/ExtCore.FileStorage.Dropbox/FileProxy.cs b/src/ExtCore.FileStorage.Dropbox/FileProxy.cs
index 7507606..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 = RelativeUrl.Combine(rootPath);
- this.RelativePath = RelativeUrl.Combine(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.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 954323a..a5e0087 100644
--- a/src/ExtCore.FileStorage.FileSystem/ExtCore.FileStorage.FileSystem.csproj
+++ b/src/ExtCore.FileStorage.FileSystem/ExtCore.FileStorage.FileSystem.csproj
@@ -1,24 +1,15 @@
+
- Dmitry Sikorsky
- Copyright © 2018 Dmitry Sikorsky
The ExtCore.FileStorage extension component. Based on the ExtCore framework.
- 7.1.3
netstandard2.0
ExtCore.FileStorage.FileSystem
ExtCore.FileStorage.FileSystem
- icon.png
- https://extcore.net/
- Apache-2.0
-
-
-
-
-
+
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