Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move away from defaulting to windows, create OS X support #68

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

cammurray
Copy link

As per #67

The defaulting to windows will create DLL errors on other platforms.

@ewilliams0305
Copy link
Owner

I'll review this shortly but agree with the approach.

Copy link
Owner

@ewilliams0305 ewilliams0305 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets go with something more like this or this to make supporting more platforms and abstractions in the future easier. I think the pattern matching will be more readable long term.

public IQueryNetworkNode CreateQuerier()
{
    return Environment.OSVersion.Platform switch
    {
        PlatformID.Win32S 
        or PlatformID.Win32Windows 
        or PlatformID.Win32Windows 
        or PlatformID.Win32NT
        or PlatformID.WinCE =>
            new QueryNetworkNode(
                logger: _logger,
                ping: _ping,
                mac: new WindowsQueryMacAddress(_logger),
                host: new QueryHostname(_logger),
                http: _clientFactory != null
                    ? new QueryWebServer(_logger, _clientFactory)
                    : null),
       
        PlatformID.Unix 
        or PlatformID.MacOSX =>
            new QueryNetworkNode(
                logger: _logger,
                ping: _ping,
                mac: new LinuxQueryMacAddress(_logger),
                host: new QueryHostname(_logger),
                http: _clientFactory != null
                    ? new QueryWebServer(_logger, _clientFactory)
                    : null),
        _ => throw new PlatformNotSupportedException()
    };
};```  

@ewilliams0305 ewilliams0305 merged commit abc7b63 into ewilliams0305:main Jul 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants