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

DUI3-464: Separates root and raw converter registration #3555

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
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 @@ -12,7 +12,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.AddSingleton(new RevitContext());

// POC: do we need ToSpeckleScalingService as is, do we need to interface it out?
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();
}
}
Loading