-
Notifications
You must be signed in to change notification settings - Fork 32
Added AddCouchContext
overloads that supply the service provider to the caller.
#210
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
base: master
Are you sure you want to change the base?
Added AddCouchContext
overloads that supply the service provider to the caller.
#210
Conversation
Added XML docs for DI methods
Updated changelogs
Hello! First of all, thanks for the PR! However, I don't fully understand the goal. In the case of the example, why use DI in the first place when you can do it without? I implemented it like Entity Framework. var settings = builder.Configuration.GetSection(nameof(DatabaseSettings)).GetValue<DatabaseSettings>();
builder.Services.AddCouchContext<DocumentsContext>(builder => builder
.UseEndpoint(settings.ServerUrl);
.UseBasicAuthentication(settings.Username, settings.Password)); Maybe a valid case is a service that resolves the server name or credentials. But then I can be easier to inject that in the context and use it in |
Yes, it is not the zenith of clever code, I added it because it adheres to how other common DI fluent APIs are designed, like AddHttpClient and so on. My Web app has many more configuration parameters than just the DB so since I need the same info all over the place registering and consuming one IOptions is "cleaner". In my opinion ofc 😜 Ultimately I wanted to eliminate having to pass around configuration variables all across my app entry and keep everything within IoC paradigms, if that makes sense. It's probably very nitpicky but hey, welcome to my world 😁 |
Got it. Still not sure about 100% to add it to the library, or at least it should be: Action<IServiceProvider, CouchOptionsBuilder<TContext>> The builder constructor was not meant to be public tbh. BTW I see it's 1+ year I don't update this library. Maybe I take a break from my stuff and work on it this week. I can release a 3.7 version with a few things in from issues and PRs, then check what I can do about |
Good call! Will modify it accordingly.
Do you need help with that? I am currently actively back in a project making heavy use of this library so I am still finding things I wanna see fixed 😉 |
That would be great! I can investigate System.Text.Json since it's now commonly used. And I can move to net8 finally |
IDK how you prefer to communicate or what your availability is like but be my guest on my Discord if you want the most direct line to me for communication 🫡 |
Cool, makes sense, joined |
Added
AddCouchContext
overloads that supply the service provider to the caller. This allows for code like:So everything stays "within" DI and is consumed by it too.