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

Add configurations to OpenTabletDriver project as embedded resource #500

Merged
merged 1 commit into from
Dec 2, 2020

Conversation

InfinityGhost
Copy link
Member

@InfinityGhost InfinityGhost commented Dec 2, 2020

Changes

  • NuGet package will build with configurations as embedded resources
  • Can be accessed with code similar to the following:
private IEnumerable<TabletConfiguration> GetConfigurations()
{
    // Retreive all embedded configurations
    var asm = typeof(Driver).Assembly;
    return from path in asm.GetManifestResourceNames()
           where path.Contains(".json")
           let stream = asm.GetManifestResourceStream(path)
           select Deserialize(stream);
}

private TabletConfiguration Deserialize(Stream stream)
{
    using (var tr = new StreamReader(stream))
    using (var jr = new JsonTextReader(tr))
        return ConfigurationSerializer.Deserialize<TabletConfiguration>(jr);
}

private JsonSerializer ConfigurationSerializer { get; } = new JsonSerializer();

@InfinityGhost InfinityGhost added enhancement New feature or request core OpenTabletDriver core library labels Dec 2, 2020
@InfinityGhost InfinityGhost added this to the v0.5.0 milestone Dec 2, 2020
@InfinityGhost InfinityGhost self-assigned this Dec 2, 2020
@InfinityGhost InfinityGhost merged commit 69a67b4 into master Dec 2, 2020
@InfinityGhost InfinityGhost deleted the embedded-resources branch December 2, 2020 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core OpenTabletDriver core library enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant