© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
28 replies
Xour

Options pattern in a shared class library

Hello all, I am looking to use options pattern in a shared class library, but I am not sure how should I go about it. The project structure is something like this:
- Api_1
    - Layer_1
    - Layer_2
    ..
- Api_2
    - Layer_1
    - Layer_2
    ..
- Shared class libraries
    - Class_library_1
    - Class_library_2
    ..
- Api_1
    - Layer_1
    - Layer_2
    ..
- Api_2
    - Layer_1
    - Layer_2
    ..
- Shared class libraries
    - Class_library_1
    - Class_library_2
    ..


What I need is to somewhat use options pattern in, say,
Class_library_2
Class_library_2
(or at least have access to the configuration provider in any way), but I am unsure what would be the proper way to do this.

If I register the config in the
Startup.cs
Startup.cs
of the
Api_1
Api_1
web project, those won't be available from
Api_2
Api_2
.

Should I create the option classes and register the config in both projects?

Any hints or advice? Thanks a lot!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Accessing class library objects from shared project
C#CC# / help
3y ago
MediatR in Class Library
C#CC# / help
2y ago
✅ Using Options pattern in MAUI
C#CC# / help
2y ago
options pattern not working
C#CC# / help
3y ago