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

Added factory builder. #194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fiseni
Copy link

@fiseni fiseni commented Feb 21, 2021

Hi,

These changes offer an alternative way of building factories. It tends to simplify the usage during the initialization/definition phase. Perhaps it's more intuitive? (that's a bit subjective). I tried not to introduce any breaking changes, so any existing code should work, the existing API remains as it is.

For now, it covers only WindowsHidDeviceFactory, and it's provided just as a sample. If this approach is preferred, then it can be extended to include the rest of the components. So, this PR is incomplete

Sample usage:

// Optional
var loggerFactory = LoggerFactory.Create((builder) =>
{
    _ = builder.AddDebug().SetMinimumLevel(LogLevel.Trace);
});

var factories = new FactoryBuilder(loggerFactory)
    .CreateWindowsHidDeviceFactory(new FilterDeviceDefinition())
    .CreateWindowsHidDeviceFactory(new FilterDeviceDefinition[]
    {
        new FilterDeviceDefinition(),
        new FilterDeviceDefinition(),
    })
    .Build();

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.

None yet

1 participant