Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto interface demo #3399

Merged
merged 6 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DUI3-DX/Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.14.1" />
<PackageReference Include="Speckle.InterfaceGenerator" Version="0.9.4" />
</ItemGroup>
</Project>
9 changes: 7 additions & 2 deletions DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Autofac.Features.Indexed;
using Speckle.InterfaceGenerator;

namespace Speckle.Autofac.DependencyInjection;

[GenerateAutoInterface]
public class Factory<TKey, TValue> : IFactory<TKey, TValue>
where TValue : class
{
Expand All @@ -14,7 +16,10 @@ public Factory(IIndex<TKey, TValue> types)

public TValue? ResolveInstance(TKey strongName)
{
_types.TryGetValue(strongName, out TValue value);
return value;
if (_types.TryGetValue(strongName, out TValue value))
{
return value;
}
return null;
}
}
12 changes: 0 additions & 12 deletions DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using Autofac;
using Speckle.InterfaceGenerator;

namespace Speckle.Autofac.DependencyInjection;

public partial interface IUnitOfWork<TService> : IDisposable
where TService : class { }

[GenerateAutoInterface]
public sealed class UnitOfWork<TService> : IUnitOfWork<TService>
where TService : class
{
Expand All @@ -14,8 +19,9 @@ public UnitOfWork(ILifetimeScope unitOfWorkScope, TService service)
Service = service;
}

public TService Service { get; private set; }
public TService Service { get; }

[AutoInterfaceIgnore]
public void Dispose() => Disposing(true);

private void Disposing(bool fromDispose)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Autofac;
using Autofac.Core;
using Speckle.InterfaceGenerator;
using Speckle.Core.Logging;

namespace Speckle.Autofac.DependencyInjection;

[GenerateAutoInterface]
public class UnitOfWorkFactory : IUnitOfWorkFactory
{
private readonly ILifetimeScope _parentScope;
Expand Down
6 changes: 0 additions & 6 deletions DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs

This file was deleted.

3 changes: 3 additions & 0 deletions DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Speckle.InterfaceGenerator;

namespace Speckle.Autofac.Files;

[GenerateAutoInterface]
public class StorageInfo : IStorageInfo
{
public IEnumerable<string> GetFilenamesInDirectory(string path, string pattern)
Expand Down