Skip to content

Commit

Permalink
Fixed #144
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Sikorsky committed Nov 26, 2018
1 parent a295b35 commit 12f4673
Show file tree
Hide file tree
Showing 34 changed files with 1,943 additions and 9 deletions.
31 changes: 31 additions & 0 deletions ExtCore.sln
Expand Up @@ -51,6 +51,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.Data.Dapper.Sqlite"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data.Dapper", "Data.Dapper", "{8C720480-750C-44C1-945B-961599088853}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FileStorage", "FileStorage", "{2093A913-AB5F-4597-839E-A472E25D37D8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage", "src\ExtCore.FileStorage\ExtCore.FileStorage.csproj", "{AD4DB805-D932-4C5F-9559-B4704340F8CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage.Abstractions", "src\ExtCore.FileStorage.Abstractions\ExtCore.FileStorage.Abstractions.csproj", "{EED241F9-4900-4FB0-91FD-432A5F40983D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage.Dropbox", "src\ExtCore.FileStorage.Dropbox\ExtCore.FileStorage.Dropbox.csproj", "{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExtCore.FileStorage.FileSystem", "src\ExtCore.FileStorage.FileSystem\ExtCore.FileStorage.FileSystem.csproj", "{2031A605-DB91-4998-94DB-8012C590152B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -129,6 +139,22 @@ Global
{693AB050-3305-471C-90C3-816BD694A930}.Debug|Any CPU.Build.0 = Debug|Any CPU
{693AB050-3305-471C-90C3-816BD694A930}.Release|Any CPU.ActiveCfg = Release|Any CPU
{693AB050-3305-471C-90C3-816BD694A930}.Release|Any CPU.Build.0 = Release|Any CPU
{AD4DB805-D932-4C5F-9559-B4704340F8CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD4DB805-D932-4C5F-9559-B4704340F8CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD4DB805-D932-4C5F-9559-B4704340F8CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD4DB805-D932-4C5F-9559-B4704340F8CA}.Release|Any CPU.Build.0 = Release|Any CPU
{EED241F9-4900-4FB0-91FD-432A5F40983D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EED241F9-4900-4FB0-91FD-432A5F40983D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EED241F9-4900-4FB0-91FD-432A5F40983D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EED241F9-4900-4FB0-91FD-432A5F40983D}.Release|Any CPU.Build.0 = Release|Any CPU
{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A}.Release|Any CPU.Build.0 = Release|Any CPU
{2031A605-DB91-4998-94DB-8012C590152B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2031A605-DB91-4998-94DB-8012C590152B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2031A605-DB91-4998-94DB-8012C590152B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2031A605-DB91-4998-94DB-8012C590152B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -157,6 +183,11 @@ Global
{E588921B-5E74-45E8-841B-2654D2416D9F} = {8C720480-750C-44C1-945B-961599088853}
{693AB050-3305-471C-90C3-816BD694A930} = {8C720480-750C-44C1-945B-961599088853}
{8C720480-750C-44C1-945B-961599088853} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
{2093A913-AB5F-4597-839E-A472E25D37D8} = {0D7AEFA3-ABB0-4AF1-A4C1-F8E05C241753}
{AD4DB805-D932-4C5F-9559-B4704340F8CA} = {2093A913-AB5F-4597-839E-A472E25D37D8}
{EED241F9-4900-4FB0-91FD-432A5F40983D} = {2093A913-AB5F-4597-839E-A472E25D37D8}
{D9FA3F92-D638-434D-9C0C-E74A6BCFDE7A} = {2093A913-AB5F-4597-839E-A472E25D37D8}
{2031A605-DB91-4998-94DB-8012C590152B} = {2093A913-AB5F-4597-839E-A472E25D37D8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF807CB9-3F57-4CF4-B501-26F9D4BB417C}
Expand Down
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.12" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.13" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ExtCore.Data.Dapper.MySql/StorageContext.cs
Expand Up @@ -14,7 +14,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the MySQL database.</param>
/// <param name="options">The options that are used to connect to the MySQL database.</param>
public StorageContext(IOptions<StorageContextOptions> options)
: base(options)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ExtCore.Data.Dapper.PostgreSql/StorageContext.cs
Expand Up @@ -14,7 +14,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the PostgreSQL database.</param>
/// <param name="options">The options that are used to connect to the PostgreSQL database.</param>
public StorageContext(IOptions<StorageContextOptions> options)
: base(options)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ExtCore.Data.Dapper.SqlServer/StorageContext.cs
Expand Up @@ -14,7 +14,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the SQL Server database.</param>
/// <param name="options">The options that are used to connect to the SQL Server database.</param>
public StorageContext(IOptions<StorageContextOptions> options)
: base(options)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ExtCore.Data.Dapper.Sqlite/StorageContext.cs
Expand Up @@ -14,7 +14,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the SQLite database.</param>
/// <param name="options">The options that are used to connect to the SQLite database.</param>
public StorageContext(IOptions<StorageContextOptions> options)
: base(options)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ExtCore.Data.EntityFramework.MySql/StorageContext.cs
Expand Up @@ -15,7 +15,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the MySQL database.</param>
/// <param name="options">The options that are used to connect to the MySQL database.</param>
public StorageContext(IOptions<StorageContextOptions> options) : base(options) { }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the PostgreSQL database.</param>
/// <param name="options">The options that are used to connect to the PostgreSQL database.</param>
public StorageContext(IOptions<StorageContextOptions> options) : base(options) { }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
Expand Down
Expand Up @@ -15,7 +15,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the SQL Server database.</param>
/// <param name="options">The options that are used to connect to the SQL Server database.</param>
public StorageContext(IOptions<StorageContextOptions> options) : base(options) { }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
Expand Down
2 changes: 1 addition & 1 deletion src/ExtCore.Data.EntityFramework.Sqlite/StorageContext.cs
Expand Up @@ -15,7 +15,7 @@ public class StorageContext : StorageContextBase
/// <summary>
/// Initializes a new instance of the <see cref="StorageContext">StorageContext</see> class.
/// </summary>
/// <param name="connectionString">The connection string that is used to connect to the SQLite database.</param>
/// <param name="options">The options that are used to connect to the SQLite database.</param>
public StorageContext(IOptions<StorageContextOptions> options)
: base(options)
{
Expand Down
@@ -0,0 +1,17 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace ExtCore.FileStorage
{
/// <summary>
/// Represents an access denied file storage exception.
/// </summary>
public class AccessDeniedException : FileStorageException
{
public AccessDeniedException() : base() { }
public AccessDeniedException(string message) : base(message) { }
public AccessDeniedException(string message, Exception innerException) : base(message, innerException) { }
}
}
@@ -0,0 +1,17 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace ExtCore.FileStorage
{
/// <summary>
/// Represents a directory not found file storage exception.
/// </summary>
public class DirectoryNotFoundException : FileStorageException
{
public DirectoryNotFoundException() : base() { }
public DirectoryNotFoundException(string message) : base(message) { }
public DirectoryNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
}
@@ -0,0 +1,17 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace ExtCore.FileStorage
{
/// <summary>
/// Represents a directory not found file storage exception.
/// </summary>
public class FileNotFoundException : FileStorageException
{
public FileNotFoundException() : base() { }
public FileNotFoundException(string message) : base(message) { }
public FileNotFoundException(string message, Exception innerException) : base(message, innerException) { }
}
}
@@ -0,0 +1,17 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace ExtCore.FileStorage
{
/// <summary>
/// Represents a generic file storage exception.
/// </summary>
public class FileStorageException : Exception
{
public FileStorageException() : base() { }
public FileStorageException(string message) : base(message) { }
public FileStorageException(string message, Exception innerException) : base(message, innerException) { }
}
}
@@ -0,0 +1,17 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;

namespace ExtCore.FileStorage
{
/// <summary>
/// Represents a path too long file storage exception.
/// </summary>
public class PathTooLongException : FileStorageException
{
public PathTooLongException() : base() { }
public PathTooLongException(string message) : base(message) { }
public PathTooLongException(string message, Exception innerException) : base(message, innerException) { }
}
}
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Authors>Dmitry Sikorsky</Authors>
<Copyright>Copyright © 2018 Dmitry Sikorsky</Copyright>
<Description>The ExtCore.FileStorage extension component. Based on the ExtCore framework.</Description>
<VersionPrefix>4.0.0-alpha1</VersionPrefix>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>ExtCore.FileStorage.Abstractions</AssemblyName>
<PackageId>ExtCore.FileStorage.Abstractions</PackageId>
<PackageIconUrl>http://extcore.net/extcore_nuget_icon.png</PackageIconUrl>
<PackageProjectUrl>http://extcore.net/</PackageProjectUrl>
</PropertyGroup>

</Project>
31 changes: 31 additions & 0 deletions src/ExtCore.FileStorage.Abstractions/FileStorageOptions.cs
@@ -0,0 +1,31 @@
// 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
{
/// <summary>
/// Represents generic file storage options.
/// </summary>
public class FileStorageOptions
{
/// <summary>
/// The origin that is used to connect to the file storage. Might be used to provide an API base URL.
/// </summary>
public string Origin { get; set; }

/// <summary>
/// The identifier that is used to connect to the file storage. Might be used to provide a username or an application identifier.
/// </summary>
public string Identifier { get; set; }

/// <summary>
/// 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.
/// </summary>
public string Secret { get; set; }

/// <summary>
/// The root path that is used by the file storage.
/// </summary>
public string RootPath { get; set; }
}
}
77 changes: 77 additions & 0 deletions src/ExtCore.FileStorage.Abstractions/IDirectoryProxy.cs
@@ -0,0 +1,77 @@
// Copyright © 2018 Dmitry Sikorsky. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ExtCore.FileStorage.Abstractions
{
/// <summary>
/// Describes a generic directory proxy to manipulate an underlying directory with a specified relative path.
/// </summary>
public interface IDirectoryProxy
{
/// <summary>
/// The path of the underlying directory relatively to the root one.
/// </summary>
string RelativePath { get; }

/// <summary>
/// Checks if the underlying directory exists.
/// </summary>
/// <returns>Returns a flag indicating if the underlying directory exists.</returns>
Task<bool> ExistsAsync();

/// <summary>
/// Creates the underlying directory.
/// </summary>
/// <exception cref="AccessDeniedException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
/// <exception cref="PathTooLongException"></exception>
/// <exception cref="FileStorageException"></exception>
Task CreateAsync();

/// <summary>
/// Moves the underlying directory.
/// </summary>
/// <param name="destinationRelativePath"></param>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AccessDeniedException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
/// <exception cref="PathTooLongException"></exception>
/// <exception cref="FileStorageException"></exception>
Task MoveAsync(string destinationRelativePath);

/// <summary>
/// Deletes the underlying directory.
/// </summary>
/// <param name="recursive">Pass true to remove all the underlying directory content recursively; otherwise false.</param>
/// <exception cref="AccessDeniedException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
/// <exception cref="PathTooLongException"></exception>
/// <exception cref="FileStorageException"></exception>
Task DeleteAsync(bool recursive);

/// <summary>
/// Gets the directory proxies for the directories inside the underlying one.
/// </summary>
/// <returns>The directory proxies for the directories inside the underlying one</returns>
/// <exception cref="AccessDeniedException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
/// <exception cref="PathTooLongException"></exception>
/// <exception cref="FileStorageException"></exception>
Task<IEnumerable<IDirectoryProxy>> GetDirectoryProxiesAsync();

/// <summary>
/// Gets the file proxies for the files inside the underlying one.
/// </summary>
/// <returns>The file proxies for the files inside the underlying directory.</returns>
/// <exception cref="AccessDeniedException"></exception>
/// <exception cref="DirectoryNotFoundException"></exception>
/// <exception cref="PathTooLongException"></exception>
/// <exception cref="FileStorageException"></exception>
Task<IEnumerable<IFileProxy>> GetFileProxiesAsync();
}
}

0 comments on commit 12f4673

Please sign in to comment.