From 1fe7e02adeca71246a3e798a41f4bbbe312df682 Mon Sep 17 00:00:00 2001 From: Claire Kuang Date: Tue, 25 Jun 2024 12:08:00 +0100 Subject: [PATCH] adds shared connector module --- Core/Core/Kits/Applications.cs | 8 ++-- .../AutocadConnectorModule.cs | 27 +------------ .../Civil3dConnectorModule.cs | 29 +------------- .../SharedConnectorModule.cs | 40 +++++++++++++++++++ ...Speckle.Connectors.AutocadShared.projitems | 1 + .../packages.lock.json | 8 +--- .../packages.lock.json | 8 +--- .../packages.lock.json | 8 +--- 8 files changed, 50 insertions(+), 79 deletions(-) create mode 100644 DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs diff --git a/Core/Core/Kits/Applications.cs b/Core/Core/Kits/Applications.cs index 9eb9962fcc..d80b63479e 100644 --- a/Core/Core/Kits/Applications.cs +++ b/Core/Core/Kits/Applications.cs @@ -120,14 +120,14 @@ public static HostApplication GetHostAppFromString(string? appname) return AutoCAD; } - if (appname.Contains("civil")) + if (appname.Contains("civil3d")) { - return Civil; + return Civil3D; } - if (appname.Contains("civil3d")) + if (appname.Contains("civil")) { - return Civil3D; + return Civil; } if (appname.Contains("rhino")) diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs index 00dca68eee..731098b249 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/AutocadConnectorModule.cs @@ -1,19 +1,11 @@ #if AUTOCAD -using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Bindings; using Speckle.Connectors.Autocad.Filters; -using Speckle.Connectors.Autocad.HostApp; -using Speckle.Connectors.Autocad.Interfaces; using Speckle.Connectors.Autocad.Operations.Receive; using Speckle.Connectors.Autocad.Operations.Send; -using Speckle.Connectors.Autocad.Plugin; -using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; @@ -25,19 +17,7 @@ public class AutocadConnectorModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddAutofac(); - builder.AddConnectorUtils(); - builder.AddDUI(); - builder.AddDUIView(); - - // Register other connector specific types - builder.AddSingleton(); - builder.AddTransient(); - builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); + SharedConnectorModule.LoadShared(builder); // Operations builder.AddScoped>(); @@ -48,12 +28,7 @@ public void Load(SpeckleContainerBuilder builder) builder.AddScoped, AutocadRootObjectBuilder>(); // Register bindings - builder.AddSingleton(); builder.AddSingleton("connectorName", "Autocad"); // POC: Easier like this for now, should be cleaned up later - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); builder.AddSingleton(); builder.AddSingleton(); diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs index 5aff6071dc..e6889843c5 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/Civil3dConnectorModule.cs @@ -1,22 +1,13 @@ #if CIVIL3D -using Speckle.Autofac; using Speckle.Autofac.DependencyInjection; using Speckle.Connectors.Autocad.Bindings; using Speckle.Connectors.Autocad.Filters; -using Speckle.Connectors.Autocad.HostApp; -using Speckle.Connectors.Autocad.Interfaces; using Speckle.Connectors.Autocad.Operations.Send; -using Speckle.Connectors.Autocad.Plugin; -using Speckle.Connectors.DUI; using Speckle.Connectors.DUI.Bindings; -using Speckle.Connectors.DUI.Models; using Speckle.Connectors.DUI.Models.Card.SendFilter; -using Speckle.Connectors.DUI.WebView; -using Speckle.Connectors.Utils; using Speckle.Connectors.Utils.Builders; using Speckle.Connectors.Utils.Caching; using Speckle.Connectors.Utils.Operations; -using Speckle.Core.Models.GraphTraversal; namespace Speckle.Connectors.Autocad.DependencyInjection; @@ -24,34 +15,16 @@ public class Civil3dConnectorModule : ISpeckleModule { public void Load(SpeckleContainerBuilder builder) { - builder.AddAutofac(); - builder.AddConnectorUtils(); - builder.AddDUI(); - builder.AddDUIView(); - - // Register other connector specific types - builder.AddSingleton(); - builder.AddTransient(); - builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); + SharedConnectorModule.LoadShared(builder); // Operations builder.AddScoped>(); - builder.AddSingleton(DefaultTraversal.CreateTraversalFunc()); // Object Builders builder.AddScoped, AutocadRootObjectBuilder>(); // Register bindings - builder.AddSingleton(); builder.AddSingleton("connectorName", "Civil3d"); // POC: Easier like this for now, should be cleaned up later - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); - builder.AddSingleton(); builder.AddSingleton(); // register send filters diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs new file mode 100644 index 0000000000..48b71d723e --- /dev/null +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/DependencyInjection/SharedConnectorModule.cs @@ -0,0 +1,40 @@ +using Speckle.Autofac; +using Speckle.Autofac.DependencyInjection; +using Speckle.Connectors.Autocad.Bindings; +using Speckle.Connectors.Autocad.HostApp; +using Speckle.Connectors.Autocad.Interfaces; +using Speckle.Connectors.Autocad.Plugin; +using Speckle.Connectors.DUI; +using Speckle.Connectors.DUI.Bindings; +using Speckle.Connectors.DUI.Models; +using Speckle.Connectors.DUI.WebView; +using Speckle.Connectors.Utils; + +namespace Speckle.Connectors.Autocad.DependencyInjection; + +public static class SharedConnectorModule +{ + public static void LoadShared(SpeckleContainerBuilder builder) + { + builder.AddAutofac(); + builder.AddConnectorUtils(); + builder.AddDUI(); + builder.AddDUIView(); + + // Register other connector specific types + builder.AddSingleton(); + builder.AddTransient(); + builder.AddSingleton(new AutocadDocumentManager()); // TODO: Dependent to TransactionContext, can be moved to AutocadContext + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + + // Register bindings + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + builder.AddSingleton(); + } +} diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems index f7b3190f39..dd0f8afa29 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.AutocadShared/Speckle.Connectors.AutocadShared.projitems @@ -13,6 +13,7 @@ + diff --git a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json index 972154724b..442462d552 100644 --- a/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json +++ b/DUI3-DX/Connectors/Autocad/Speckle.Connectors.Civil3d2024/packages.lock.json @@ -288,11 +288,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -496,8 +491,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json index f16bd97d53..90415ed373 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024.DependencyInjection/packages.lock.json @@ -213,11 +213,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -374,8 +369,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "speckle.converters.common.dependencyinjection": { diff --git a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json index b4a7488317..7e24ff76cb 100644 --- a/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json +++ b/DUI3-DX/Converters/Autocad/Speckle.Converters.Autocad2024/packages.lock.json @@ -205,11 +205,6 @@ "resolved": "13.0.2", "contentHash": "g1BejUZwax5PRfL6xHgLEK23sqHWOgOj9hE7RvfRRlN00AGt8GnPYt8HedSK7UB3HiRW8zCA9Pn0iiYxCK24BA==" }, - "Speckle.Revit2023.Interfaces": { - "type": "Transitive", - "resolved": "0.1.1-preview.0.24", - "contentHash": "BSVpOUJc9g6ISrw8GxvtkglTlITpHEDYNOhxv1ZPbckBsI0yO36JiphhQV4q57ERqD9PpCozUJkVhlCaxWeS6A==" - }, "SQLitePCLRaw.bundle_e_sqlite3": { "type": "Transitive", "resolved": "2.1.4", @@ -359,8 +354,7 @@ "type": "Project", "dependencies": { "Speckle.Autofac": "[2.0.999-local, )", - "Speckle.Objects": "[2.0.999-local, )", - "Speckle.Revit2023.Interfaces": "[0.1.1-preview.0.24, )" + "Speckle.Objects": "[2.0.999-local, )" } }, "Speckle.Core": {