@@ -34,12 +34,17 @@ Note: This library is currently distributed as source. A NuGet package may be av
3434using GeneralUpdate .Extension ;
3535using GeneralUpdate .Extension .Metadata ;
3636
37- // Create extension host
38- var host = new ExtensionHost (
39- hostVersion : new Version (1 , 0 , 0 ),
40- installPath : @" C:\MyApp\Extensions" ,
41- downloadPath : @" C:\MyApp\Downloads" ,
42- targetPlatform : TargetPlatform .Windows );
37+ // Create extension host with configuration
38+ var config = new ExtensionHostConfig
39+ {
40+ HostVersion = new Version (1 , 0 , 0 ),
41+ InstallBasePath = @" C:\MyApp\Extensions" ,
42+ DownloadPath = @" C:\MyApp\Downloads" ,
43+ ServerUrl = " https://your-server.com/api/extensions" ,
44+ TargetPlatform = TargetPlatform .Windows
45+ };
46+
47+ var host = new GeneralExtensionHost (config );
4348
4449// Load installed extensions
4550host .LoadInstalledExtensions ();
@@ -70,25 +75,29 @@ public class YourModule : IModule
7075{
7176 public void RegisterTypes (IContainerRegistry containerRegistry )
7277 {
73- var hostVersion = new Version (1 , 0 , 0 );
74- var installPath = @" C:\MyApp\Extensions" ;
75- var downloadPath = @" C:\MyApp\Downloads" ;
76- var platform = Metadata .TargetPlatform .Windows ;
78+ var config = new ExtensionHostConfig
79+ {
80+ HostVersion = new Version (1 , 0 , 0 ),
81+ InstallBasePath = @" C:\MyApp\Extensions" ,
82+ DownloadPath = @" C:\MyApp\Downloads" ,
83+ ServerUrl = " https://your-server.com/api/extensions" ,
84+ TargetPlatform = Metadata .TargetPlatform .Windows
85+ };
7786
7887 // Register as singletons
7988 containerRegistry .RegisterSingleton <Core .IExtensionCatalog >(() =>
80- new Core .ExtensionCatalog (installPath ));
89+ new Core .ExtensionCatalog (config . InstallBasePath ));
8190
8291 containerRegistry .RegisterSingleton <Compatibility .ICompatibilityValidator >(() =>
83- new Compatibility .CompatibilityValidator (hostVersion ));
92+ new Compatibility .CompatibilityValidator (config . HostVersion ));
8493
8594 containerRegistry .RegisterSingleton <Download .IUpdateQueue , Download .UpdateQueue >();
8695
8796 containerRegistry .RegisterSingleton < PackageGeneration .IExtensionPackageGenerator ,
8897 PackageGeneration .ExtensionPackageGenerator > ();
8998
9099 containerRegistry .RegisterSingleton <IExtensionHost >(() =>
91- new ExtensionHost ( hostVersion , installPath , downloadPath , platform ));
100+ new GeneralExtensionHost ( config ));
92101 }
93102}
94103
@@ -102,24 +111,28 @@ var host = container.Resolve<IExtensionHost>();
102111using Microsoft .Extensions .DependencyInjection ;
103112
104113var services = new ServiceCollection ();
105- var hostVersion = new Version (1 , 0 , 0 );
106- var installPath = @" C:\Extensions" ;
107- var downloadPath = @" C:\Downloads" ;
114+ var config = new ExtensionHostConfig
115+ {
116+ HostVersion = new Version (1 , 0 , 0 ),
117+ InstallBasePath = @" C:\Extensions" ,
118+ DownloadPath = @" C:\Downloads" ,
119+ ServerUrl = " https://your-server.com/api/extensions" ,
120+ TargetPlatform = Metadata .TargetPlatform .Windows
121+ };
108122
109123services .AddSingleton <Core .IExtensionCatalog >(sp =>
110- new Core .ExtensionCatalog (installPath ));
124+ new Core .ExtensionCatalog (config . InstallBasePath ));
111125
112126services .AddSingleton <Compatibility .ICompatibilityValidator >(sp =>
113- new Compatibility .CompatibilityValidator (hostVersion ));
127+ new Compatibility .CompatibilityValidator (config . HostVersion ));
114128
115129services .AddSingleton <Download .IUpdateQueue , Download .UpdateQueue >();
116130
117131services .AddSingleton < PackageGeneration .IExtensionPackageGenerator ,
118132 PackageGeneration .ExtensionPackageGenerator > ();
119133
120134services .AddSingleton <IExtensionHost >(sp =>
121- new ExtensionHost (hostVersion , installPath , downloadPath ,
122- Metadata .TargetPlatform .Windows ));
135+ new GeneralExtensionHost (config ));
123136
124137var provider = services .BuildServiceProvider ();
125138var host = provider .GetRequiredService <IExtensionHost >();
@@ -128,11 +141,16 @@ var host = provider.GetRequiredService<IExtensionHost>();
128141#### Without DI (Direct Instantiation)
129142
130143``` csharp
131- var host = new ExtensionHost (
132- new Version (1 , 0 , 0 ),
133- @" C:\Extensions" ,
134- @" C:\Downloads" ,
135- Metadata .TargetPlatform .Windows );
144+ var config = new ExtensionHostConfig
145+ {
146+ HostVersion = new Version (1 , 0 , 0 ),
147+ InstallBasePath = @" C:\Extensions" ,
148+ DownloadPath = @" C:\Downloads" ,
149+ ServerUrl = " https://your-server.com/api/extensions" ,
150+ TargetPlatform = Metadata .TargetPlatform .Windows
151+ };
152+
153+ var host = new GeneralExtensionHost (config );
136154```
137155
138156### 2. Loading and Managing Extensions
0 commit comments