|
3 | 3 | using System.Reflection;
|
4 | 4 | using Autodesk.Revit.UI;
|
5 | 5 | using Autodesk.Revit.Attributes;
|
6 |
| -using Microsoft.Extensions.DependencyInjection; |
7 |
| -using Microsoft.Extensions.Logging; |
8 | 6 | using pyRevitAssemblyBuilder.AssemblyMaker;
|
9 | 7 | using pyRevitAssemblyBuilder.SessionManager;
|
10 |
| -using pyRevitAssemblyBuilder.Shared; |
11 |
| -using pyRevitAssemblyBuilder.Startup; |
| 8 | +using pyRevitAssemblyBuilder.FolderParser; |
12 | 9 |
|
13 | 10 | /* Note:
|
14 | 11 | * It is necessary that this code object do not have any references to IronPython.
|
@@ -112,31 +109,21 @@ public static Result ExecuteStartUpCsharp(UIControlledApplication uiControlledAp
|
112 | 109 | var fi = uiControlledApplication.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
113 | 110 | var uiApplication = (UIApplication)fi.GetValue(uiControlledApplication);
|
114 | 111 |
|
115 |
| - var services = new ServiceCollection(); |
116 |
| - services.AddLogging(cfg => cfg.AddDebug()); |
117 |
| - |
118 |
| - // Add Revit UIApplication to services |
119 |
| - services.AddSingleton(uiApplication); |
120 |
| - |
121 |
| - // Add known services |
122 |
| - services.AddSingleton<ICommandTypeGenerator, DefaultCommandTypeGenerator>(); |
123 |
| - services.AddSingleton<IHookManager, DummyHookManager>(); |
124 |
| - services.AddSingleton<IUIManager, UIManagerService>(); |
125 |
| - services.AddSingleton<ISessionManager, SessionManagerService>(); |
126 |
| - services.AddSingleton<IExtensionManager, ExtensionManagerService>(); |
127 |
| - |
128 |
| - // Register AssemblyBuilderService with explicit string parameter |
129 |
| - services.AddSingleton<AssemblyBuilderService>(sp => |
130 |
| - new AssemblyBuilderService( |
131 |
| - sp.GetRequiredService<ICommandTypeGenerator>(), |
132 |
| - versionNumber |
133 |
| - ) |
| 112 | + // Instantiate all services |
| 113 | + var typeGenerator = new CommandTypeGenerator(); |
| 114 | + var assemblyBuilder = new AssemblyBuilderService(typeGenerator, versionNumber); |
| 115 | + var extensionManager = new ExtensionManagerService(); |
| 116 | + var hookManager = new HookManager(); |
| 117 | + var uiManager = new UIManagerService(uiApplication); |
| 118 | + |
| 119 | + var sessionManager = new SessionManagerService( |
| 120 | + assemblyBuilder, |
| 121 | + extensionManager, |
| 122 | + hookManager, |
| 123 | + uiManager |
134 | 124 | );
|
135 | 125 |
|
136 |
| - var serviceProvider = services.BuildServiceProvider(); |
137 |
| - var sessionManager = serviceProvider.GetRequiredService<ISessionManager>(); |
138 |
| - sessionManager.LoadSessionAsync().Wait(); |
139 |
| - |
| 126 | + sessionManager.LoadSession(); |
140 | 127 | return Result.Succeeded;
|
141 | 128 | }
|
142 | 129 | catch (Exception ex)
|
|
0 commit comments