Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dui3/alpha' into DUI3-177-Levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Ivy committed Jul 3, 2024
2 parents 34f75b3 + a2954b1 commit a8e8d1f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ public class ArcGISConverterModule : ISpeckleModule
{
public void Load(SpeckleContainerBuilder builder)
{
// add single root converter
//don't need a host specific RootToSpeckleConverter
builder.AddConverterCommon<RootToSpeckleConverter, ArcGISToSpeckleUnitConverter, Unit>();
builder.AddRootCommon<RootToSpeckleConverter>();

// add application converters
builder.AddApplicationConverters<ArcGISToSpeckleUnitConverter, Unit>();

// most things should be InstancePerLifetimeScope so we get one per operation
builder.AddScoped<IFeatureClassUtils, FeatureClassUtils>();
builder.AddScoped<IArcGISFieldUtils, ArcGISFieldUtils>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Speckle.Autofac.DependencyInjection;
using Speckle.Converters.Autocad;
Expand All @@ -11,9 +11,11 @@ public class AutocadConverterModule : ISpeckleModule
{
public void Load(SpeckleContainerBuilder builder)
{
builder.AddConverterCommon<AutocadRootToHostConverter, AutocadToSpeckleUnitConverter, UnitsValue>();
// add single root converter
builder.AddRootCommon<AutocadRootToHostConverter>();

// single stack per conversion
// add application converters and context stack
builder.AddApplicationConverters<AutocadToSpeckleUnitConverter, UnitsValue>();
builder.AddScoped<IConversionContextStack<Document, UnitsValue>, AutocadConversionContextStack>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ public class AutocadConverterModule : ISpeckleModule
{
public void Load(SpeckleContainerBuilder builder)
{
builder.AddConverterCommon<AutocadRootToHostConverter, AutocadToSpeckleUnitConverter, UnitsValue>();
// add single root converter
builder.AddRootCommon<AutocadRootToHostConverter>();

// single stack per conversion
// add application converters and context stack
builder.AddApplicationConverters<AutocadToSpeckleUnitConverter, UnitsValue>();
builder.AddScoped<IConversionContextStack<Document, UnitsValue>, AutocadConversionContextStack>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public class RevitConverterModule : ISpeckleModule
{
public void Load(SpeckleContainerBuilder builder)
{
builder.AddConverterCommon<RevitRootToSpeckleConverter, RevitToSpeckleUnitConverter, ForgeTypeId>();
// Register single root
builder.AddRootCommon<RevitRootToSpeckleConverter>();

// register all application converters
builder.AddApplicationConverters<RevitToSpeckleUnitConverter, ForgeTypeId>();

builder.AddScoped<IRootToHostConverter, RevitRootToHostConverter>();
builder.AddSingleton(new RevitContext());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ public class RhinoConverterModule : ISpeckleModule
{
public void Load(SpeckleContainerBuilder builder)
{
builder.AddConverterCommon<RootToSpeckleConverter, RhinoToSpeckleUnitConverter, UnitSystem>();
// single stack per conversion
// Register single root
builder.AddRootCommon<RootToSpeckleConverter>();

// register all application converters and context stacks
builder.AddApplicationConverters<RhinoToSpeckleUnitConverter, UnitSystem>();
builder.AddScoped<IConversionContextStack<RhinoDoc, UnitSystem>, RhinoConversionContextStack>();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
using Speckle.Autofac.DependencyInjection;
using Speckle.Autofac.DependencyInjection;
using Speckle.Converters.Common.DependencyInjection.ToHost;
using Speckle.Converters.Common.Objects;

namespace Speckle.Converters.Common.DependencyInjection;

public static class ContainerRegistration
{
public static void AddConverterCommon<TRootToSpeckleConverter, THostToSpeckleUnitConverter, THostUnit>(
this SpeckleContainerBuilder builder
)
public static void AddRootCommon<TRootToSpeckleConverter>(this SpeckleContainerBuilder builder)
where TRootToSpeckleConverter : class, IRootToSpeckleConverter
where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter<THostUnit>
{
builder.AddScoped<IRootToSpeckleConverter, TRootToSpeckleConverter>();
builder.AddScoped<IHostToSpeckleUnitConverter<THostUnit>, THostToSpeckleUnitConverter>();
/*
POC: CNX-9267 Moved the Injection of converters into the converter module. Not sure if this is 100% right, as this doesn't just register the conversions within this converter, but any conversions found in any Speckle.*.dll file.
This will require consolidating across other connectors.
Expand All @@ -29,8 +25,16 @@ This will require consolidating across other connectors.

builder.AddScoped<IRootToHostConverter, ConverterWithFallback>();

builder.RegisterRawConversions();
builder.InjectNamedTypes<IToSpeckleTopLevelConverter>();
builder.InjectNamedTypes<IToHostTopLevelConverter>();
}

public static void AddApplicationConverters<THostToSpeckleUnitConverter, THostUnits>(
this SpeckleContainerBuilder builder
)
where THostToSpeckleUnitConverter : class, IHostToSpeckleUnitConverter<THostUnits>
{
builder.AddScoped<IHostToSpeckleUnitConverter<THostUnits>, THostToSpeckleUnitConverter>();
builder.RegisterRawConversions();
}
}

0 comments on commit a8e8d1f

Please sign in to comment.