CreateHost() private method

private CreateHost ( Type? startupType, AssemblyName, assemblyName, IMessageSink diagnosticMessageSink ) : IHost?
startupType Type?
assemblyName AssemblyName,
diagnosticMessageSink IMessageSink
return IHost?
コード例 #1
0
    public IHost?BuildDefaultHost()
    {
        _defaultStartupType = StartupLoader.GetStartupType(_assemblyName);

        _host = StartupLoader.CreateHost(_defaultStartupType, _assemblyName, _diagnosticMessageSink);

        if (_host != null)
        {
            _hosts.Add(_host);
        }

        return(_host);
    }
コード例 #2
0
    public IHost?GetHost(Type?type)
    {
        if (type == null)
        {
            return(_host);
        }

        var startupType = FindStartup(type, out var shared);

        if (startupType == null)
        {
            return(_host);
        }

        if (shared)
        {
            if (_hostMap.TryGetValue(startupType, out var startup))
            {
                return(startup);
            }

            if (startupType == _defaultStartupType)
            {
                return(_hostMap[startupType] = _host !);
            }
        }

        var host = StartupLoader.CreateHost(startupType, _assemblyName, _diagnosticMessageSink);

        if (!shared)
        {
            _hostMap[startupType] = host;
        }

        _hosts.Add(host);

        return(host);
    }