GtkSharp icon indicating copy to clipboard operation
GtkSharp copied to clipboard

Generic Host Builder

Open Css-IanM opened this issue 5 years ago • 15 comments

I'm currently working on implementing the Host Builder to facilitate logging, DI, Entity Framework, etc in a dotnet core standardized way. Is this something that should be considered for updating the templates to use as well? Or should it just stay Opt in as is currently?

Css-IanM avatar Dec 04 '19 17:12 Css-IanM

With the template update and usage of dependency inject this could also involve updating the samples to utilize the full infrastructure of what host provides. It could lead to a cleaner implementation in the long run i think. That's just my opinion though. I'll introduce a PR to show exactly what I'm referring to though.

Css-IanM avatar Dec 04 '19 20:12 Css-IanM

I have no idea what this is.

harry-cpp avatar Dec 04 '19 20:12 harry-cpp

Basically using Microsoft's built in DI and Core services, just like any other dotnet Core application template. Work In Progress - https://github.com/Css-IanM/GtkSharp/blob/HostBuilder/Source/Templates/GtkSharp.Template.CSharp/content/GtkSharp.Application.CSharp/Program.cs

Css-IanM avatar Dec 04 '19 21:12 Css-IanM

So a paradigm, I wouldn't want to add something like this to the templates, they are there just for making a blank app, nothing more.

harry-cpp avatar Dec 04 '19 21:12 harry-cpp

So maybe some content for the Wiki then? Something along the lines of a How To?

Css-IanM avatar Dec 04 '19 21:12 Css-IanM

Sure.

harry-cpp avatar Dec 04 '19 21:12 harry-cpp

Great idea, @Css-IanM . But why do you only use singletons in your example?

How console apps manages transient and scoped services?

knuxbbs avatar Dec 11 '19 20:12 knuxbbs

I never used this di system but in general you would do it to get access to the main window (if there should only be one) from other points of your code

badcel avatar Dec 12 '19 04:12 badcel

@knuxbbs You would use the scope/life cycle that applies to your requirements. I planned to update more to utilize sockets for subsequent views within the main window, a pseudo router if you will, hence singleton in the example.

Css-IanM avatar Dec 12 '19 14:12 Css-IanM

I intend on creating a baseline Seed starter project based on this pattern, the above linked example was just a proof of concept. I will hopefully have some time for open source this weekend to get it going. I will link the repo here once its more fleshed out. While i'm working on that i'll be documenting the process so that i can organize and layout a wiki article for this repo. Hopefully this helps someone down the line.

Css-IanM avatar Dec 12 '19 14:12 Css-IanM

@Css-IanM I've been tested your example and it's doesn't works.

Error message: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed

knuxbbs avatar Dec 30 '19 21:12 knuxbbs

The example linked is an unfinished Work In Progress used to describe the issue before putting additional time. The paradigm however does work and I can help with a fully fledged example if you wish, time for open source is limited on my end.

Edit: your error listed above is familiar to me, though i cannot remember everything i did with initial testing. There was DI Container specifics and GTK depenendencies i had to register before any consuming classes. I have the working example at my office that works completely and I will push it up to the example for your reference.

Css-IanM avatar Dec 30 '19 22:12 Css-IanM

@knuxbbs Here is an example repo with the full paradigm implemented. i think i also added sql server entity framework core to it as well, i just cant remember how far i actually took it.

Css-IanM avatar Dec 31 '19 14:12 Css-IanM

Wow, thanks!

And a great 2020 to the GtkSharp community!

knuxbbs avatar Dec 31 '19 23:12 knuxbbs

You can also take a look at this, I modeled the generic host extension copied by aspnetcore https://github.com/TheForgetTime/GtkSharp.Hosting.git

It contains an example using the sqlite entity framework core

ghost avatar Feb 04 '21 00:02 ghost