Skip to content

Commit e2e664f

Browse files
authored
Auto interface demo (#3399)
* Demo of InterfaceGenerator * fmt * use new package * update autointerface again * fix autogenerated interfaces
1 parent c0d0262 commit e2e664f

File tree

9 files changed

+20
-37
lines changed

9 files changed

+20
-37
lines changed

DUI3-DX/Directory.Build.Props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="PolySharp" Version="1.14.1" />
12+
<PackageReference Include="Speckle.InterfaceGenerator" Version="0.9.4" />
1213
</ItemGroup>
1314
</Project>

DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/Factory.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using Autofac.Features.Indexed;
2+
using Speckle.InterfaceGenerator;
23

34
namespace Speckle.Autofac.DependencyInjection;
45

6+
[GenerateAutoInterface]
57
public class Factory<TKey, TValue> : IFactory<TKey, TValue>
68
where TValue : class
79
{
@@ -14,7 +16,10 @@ public Factory(IIndex<TKey, TValue> types)
1416

1517
public TValue? ResolveInstance(TKey strongName)
1618
{
17-
_types.TryGetValue(strongName, out TValue value);
18-
return value;
19+
if (_types.TryGetValue(strongName, out TValue value))
20+
{
21+
return value;
22+
}
23+
return null;
1924
}
2025
}

DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IFactory.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWork.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/IUnitOfWorkFactory.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWork.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
using Autofac;
2+
using Speckle.InterfaceGenerator;
23

34
namespace Speckle.Autofac.DependencyInjection;
45

6+
public partial interface IUnitOfWork<TService> : IDisposable
7+
where TService : class { }
8+
9+
[GenerateAutoInterface]
510
public sealed class UnitOfWork<TService> : IUnitOfWork<TService>
611
where TService : class
712
{
@@ -14,8 +19,9 @@ public UnitOfWork(ILifetimeScope unitOfWorkScope, TService service)
1419
Service = service;
1520
}
1621

17-
public TService Service { get; private set; }
22+
public TService Service { get; }
1823

24+
[AutoInterfaceIgnore]
1925
public void Dispose() => Disposing(true);
2026

2127
private void Disposing(bool fromDispose)

DUI3-DX/Sdk/Speckle.Autofac/DependencyInjection/UnitOfWorkFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using Autofac;
22
using Autofac.Core;
3+
using Speckle.InterfaceGenerator;
34
using Speckle.Core.Logging;
45

56
namespace Speckle.Autofac.DependencyInjection;
67

8+
[GenerateAutoInterface]
79
public class UnitOfWorkFactory : IUnitOfWorkFactory
810
{
911
private readonly ILifetimeScope _parentScope;

DUI3-DX/Sdk/Speckle.Autofac/Files/IStorageInfo.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

DUI3-DX/Sdk/Speckle.Autofac/Files/StorageInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
using Speckle.InterfaceGenerator;
2+
13
namespace Speckle.Autofac.Files;
24

5+
[GenerateAutoInterface]
36
public class StorageInfo : IStorageInfo
47
{
58
public IEnumerable<string> GetFilenamesInDirectory(string path, string pattern)

0 commit comments

Comments
 (0)