Function to extract all di entities by type
See original GitHub issueStarted in slack
Could you provide a way to extract all DI entities (with their tags) from a DI container? This would be very useful for CLI applications, where you have some tagged processors controlled by cli flag that do same work in different context. Consider this example using kotlinx-cli:
val di = DI {
bind<MavenScannerService<*>>("mavenCentral") with singleton { MavenScannerServiceImpl(...) }
bind<MavenScannerService<*>>("jCenter") with singleton { MavenScannerServiceImpl(...) }
bind<MavenScannerService<*>>("google") with singleton { MavenScannerServiceImpl(...) }
}
fun main(args: Array<string>) {
val parser = ArgParser("scanner")
val scanners: Set<Pair<String?, DIProvider<MavenScannerService<*>>>> = di.direct.allProviderBindings<MavenScannerService<*>>() // <--------------- New API, alternatives for instances and factories omitted
val scanner by parser.argument(
type = ArgType.Choice(scanners.mapNotNull { it.first }, { scanners.find { (tag, _) -> it == tag } }),
description = "Repository alias to scan for"
)
parser.parse(args)
// do stuff with scanner
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Extract custom entities from documents in their native format ...
You can now use natural language processing (NLP) to extract custom entities from your PDF, Word, and plain text documents using the same...
Read more >Use Custom Entity Extraction AI Model to Extract ... - YouTube
Use Custom Entity Extraction AI Model to Extract the Useful Entities from your Business Data · Key moments. View all · Key moments...
Read more >Extracting Entities with Automated Data Wrappers
Google shows us how automated data wrappers may be used to extract entity information from web pages and make The knowledge graph better....
Read more >Extracting and Representing Entities, Types, and Relations
for extracting all entities and long-range relations simultaneously over full paragraphs while jointly linking these entities to a KG.
Read more >The entity cannot be constructed in a LINQ to Entities query
The entity cannot be constructed in a LINQ to Entities query · System.NotSupportedException: 'The entity or complex type 'StudentInfoAjax.Models. · You can map...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will think about that. This is kind of hacking the container, I will see if we really want to document this.
If so, I will create a another issue. Thx
While this definitely solves my issue, could I ask that this issue is reopened in order to lift up those undocumented APIs into public domain?