refactor: rewire Program.cs DI — remove API/DB, add Excel and log services
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+11
-25
@@ -1,18 +1,12 @@
|
|||||||
using ExportDXF.ApiClient;
|
|
||||||
using ExportDXF.Forms;
|
using ExportDXF.Forms;
|
||||||
using ExportDXF.Services;
|
using ExportDXF.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Configuration;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ExportDXF
|
namespace ExportDXF
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
@@ -25,40 +19,32 @@ namespace ExportDXF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Simple dependency injection container.
|
|
||||||
/// </summary>
|
|
||||||
public class ServiceContainer
|
public class ServiceContainer
|
||||||
{
|
{
|
||||||
private readonly string _apiBaseUrl;
|
|
||||||
|
|
||||||
public ServiceContainer()
|
|
||||||
{
|
|
||||||
_apiBaseUrl = ConfigurationManager.AppSettings["FabWorksApiUrl"] ?? "http://localhost:5206";
|
|
||||||
}
|
|
||||||
|
|
||||||
public MainForm ResolveMainForm()
|
public MainForm ResolveMainForm()
|
||||||
{
|
{
|
||||||
var solidWorksService = new SolidWorksService();
|
var solidWorksService = new SolidWorksService();
|
||||||
var bomExtractor = new BomExtractor();
|
var bomExtractor = new BomExtractor();
|
||||||
var partExporter = new PartExporter();
|
var partExporter = new PartExporter();
|
||||||
var drawingExporter = new DrawingExporter();
|
var drawingExporter = new DrawingExporter();
|
||||||
|
var excelExportService = new ExcelExportService();
|
||||||
var httpClient = new HttpClient
|
var logFileService = new LogFileService();
|
||||||
{
|
|
||||||
BaseAddress = new Uri(_apiBaseUrl),
|
|
||||||
Timeout = TimeSpan.FromSeconds(30)
|
|
||||||
};
|
|
||||||
var apiClient = new FabWorksApiClient(httpClient);
|
|
||||||
|
|
||||||
var exportService = new DxfExportService(
|
var exportService = new DxfExportService(
|
||||||
solidWorksService,
|
solidWorksService,
|
||||||
bomExtractor,
|
bomExtractor,
|
||||||
partExporter,
|
partExporter,
|
||||||
drawingExporter,
|
drawingExporter,
|
||||||
apiClient);
|
excelExportService,
|
||||||
|
logFileService);
|
||||||
|
|
||||||
return new MainForm(solidWorksService, exportService, apiClient);
|
var extractors = new IDrawingInfoExtractor[]
|
||||||
|
{
|
||||||
|
new EquipmentDrawingInfoExtractor(),
|
||||||
|
new DefaultDrawingInfoExtractor()
|
||||||
|
};
|
||||||
|
|
||||||
|
return new MainForm(solidWorksService, exportService, extractors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user