fixes some record types and type visibility
adds project for autofac setup
This commit is contained in:
parent
c4e1eb4923
commit
a314b3a454
@ -0,0 +1,26 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Autofac;
|
||||
|
||||
namespace Piwigo.Client.Autofac;
|
||||
|
||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public static class ContainerBuilderExtensions
|
||||
{
|
||||
public static ContainerBuilder RegisterPiwigo(this ContainerBuilder builder, IPiwigoConfiguration configuration)
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
if (configuration == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(configuration));
|
||||
}
|
||||
|
||||
builder.RegisterModule(new PiwigoModule(configuration));
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Piwigo.Client\Piwigo.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
26
PiwigoDotnet/Piwigo.Client.Autofac/PiwigoModule.cs
Normal file
26
PiwigoDotnet/Piwigo.Client.Autofac/PiwigoModule.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Autofac;
|
||||
|
||||
namespace Piwigo.Client.Autofac;
|
||||
|
||||
public sealed class PiwigoModule : Module
|
||||
{
|
||||
private readonly IPiwigoConfiguration _configuration;
|
||||
|
||||
public PiwigoModule(IPiwigoConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
}
|
||||
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
base.Load(builder);
|
||||
|
||||
builder.RegisterInstance(() => _configuration).AsImplementedInterfaces();
|
||||
builder.RegisterType<PiwigoContext>().AsImplementedInterfaces().InstancePerLifetimeScope();
|
||||
builder.RegisterType<AlbumApi>().AsImplementedInterfaces();
|
||||
builder.RegisterType<ImageApi>().AsImplementedInterfaces();
|
||||
builder.RegisterType<SessionApi>().AsImplementedInterfaces();
|
||||
builder.RegisterType<TagApi>().AsImplementedInterfaces();
|
||||
builder.RegisterType<PiwigoClient>().AsImplementedInterfaces();
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public record AlbumList
|
||||
internal record AlbumList
|
||||
{
|
||||
[JsonProperty("Categories")]
|
||||
public IList<Album> Albums { get; init; } = null!;
|
||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public record CheckUpload
|
||||
internal record CheckUpload
|
||||
{
|
||||
[JsonProperty("message")]
|
||||
public string? Message { get; init; }
|
||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public record CommentAdded
|
||||
internal record CommentAdded
|
||||
{
|
||||
[JsonProperty("comment")]
|
||||
public Comment Comment { get; init; } = null!;
|
||||
|
@ -2,18 +2,8 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public class PagedImages
|
||||
public record PagedImages
|
||||
{
|
||||
protected PagedImages()
|
||||
{
|
||||
}
|
||||
|
||||
public PagedImages(ImagePagingInfo paging, IReadOnlyCollection<Image> images)
|
||||
{
|
||||
Paging = paging ?? throw new ArgumentNullException(nameof(paging));
|
||||
Images = images ?? throw new ArgumentNullException(nameof(images));
|
||||
}
|
||||
|
||||
[JsonProperty("paging")]
|
||||
public ImagePagingInfo Paging { get; init; } = null!;
|
||||
|
||||
|
@ -2,7 +2,7 @@ using Newtonsoft.Json;
|
||||
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public class PiwigoResponse
|
||||
public record PiwigoResponse
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool IsOk => Status is not null && Status.ToLower().Equals("ok");
|
||||
@ -17,7 +17,7 @@ public class PiwigoResponse
|
||||
public string? Message { get; init; }
|
||||
}
|
||||
|
||||
public class PiwigoResponse<T> : PiwigoResponse
|
||||
public record PiwigoResponse<T> : PiwigoResponse
|
||||
{
|
||||
[JsonProperty("result")]
|
||||
public T Result { get; init; } = default!;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace Piwigo.Client;
|
||||
namespace Piwigo.Client.Contract;
|
||||
|
||||
public enum ThumbnailSize
|
||||
{
|
@ -1,3 +1,5 @@
|
||||
namespace Piwigo.Client;
|
||||
|
||||
public interface ITagApi {}
|
||||
public interface ITagApi
|
||||
{
|
||||
}
|
@ -3,7 +3,7 @@ using Piwigo.Client.Contract;
|
||||
|
||||
namespace Piwigo.Client;
|
||||
|
||||
internal class SessionApi : ISessionApi
|
||||
public class SessionApi : ISessionApi
|
||||
{
|
||||
private readonly IPiwigoContext _context;
|
||||
private readonly ILogger<SessionApi> _logger;
|
||||
|
5
PiwigoDotnet/Piwigo.Client/TagApi.cs
Normal file
5
PiwigoDotnet/Piwigo.Client/TagApi.cs
Normal file
@ -0,0 +1,5 @@
|
||||
namespace Piwigo.Client;
|
||||
|
||||
public class TagApi : ITagApi
|
||||
{
|
||||
}
|
@ -6,6 +6,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwigo.Client.Tests", "Piwi
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwigo.Client.Cli", "Piwigo.Client.Cli\Piwigo.Client.Cli.csproj", "{829494FB-DE53-4C65-958D-37036CAB86BD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Piwigo.Client.Autofac", "Piwigo.Client.Autofac\Piwigo.Client.Autofac.csproj", "{C8247110-D9BB-4658-B36B-7AEB7A42C8EC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -24,5 +26,9 @@ Global
|
||||
{829494FB-DE53-4C65-958D-37036CAB86BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{829494FB-DE53-4C65-958D-37036CAB86BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{829494FB-DE53-4C65-958D-37036CAB86BD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C8247110-D9BB-4658-B36B-7AEB7A42C8EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
Loading…
Reference in New Issue
Block a user