Skip to content

Commit ec80b78

Browse files
committed
make the MEF loading earlier
1 parent cc2797b commit ec80b78

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

SocketBase/AppServerBase.cs

+16-10
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,27 @@ void CommandLoaderOnError(object sender, ErrorEventArgs e)
364364
}
365365

366366
/// <summary>
367-
/// Setups with the specified configurations.
367+
/// Gets the composition container.
368368
/// </summary>
369-
/// <param name="rootConfig">The root configuration.</param>
370-
/// <param name="config">The server configuration.</param>
369+
/// <param name="config">The configuration.</param>
371370
/// <returns></returns>
372-
protected virtual bool Setup(IRootConfig rootConfig, IServerConfig config)
371+
protected virtual ExportProvider GetCompositionContainer(IServerConfig config)
373372
{
374373
var catalog = new AggregateCatalog();
375374
catalog.Catalogs.Add(new AssemblyCatalog(typeof(IAppServer).Assembly));
376375
catalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory, "*.dll"));
377-
var compositionContainer = new CompositionContainer(catalog);
378-
379-
if (!Setup(rootConfig, config, compositionContainer))
380-
return false;
376+
return new CompositionContainer(catalog);
377+
}
381378

382-
CompositionContainer = compositionContainer;
383-
return true;
379+
/// <summary>
380+
/// Setups with the specified configurations.
381+
/// </summary>
382+
/// <param name="rootConfig">The root configuration.</param>
383+
/// <param name="config">The server configuration.</param>
384+
/// <returns></returns>
385+
protected virtual bool Setup(IRootConfig rootConfig, IServerConfig config)
386+
{
387+
return Setup(rootConfig, config, CompositionContainer);
384388
}
385389

386390
/// <summary>
@@ -429,6 +433,8 @@ private void SetupBasic(IRootConfig rootConfig, IServerConfig config, ISocketSer
429433
m_ThreadPoolConfigured = true;
430434
}
431435

436+
CompositionContainer = GetCompositionContainer(config);
437+
432438
if (socketServerFactory == null)
433439
{
434440
var socketServerFactoryType =

0 commit comments

Comments
 (0)