question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic type decorators

See original GitHub issue

Is it possible to register the following (assuming MyRepositoryA and MyRepositoryB already registered as implemented intefaces)? services.AddSingleton<IRepositoryFactory<IMyRepositoryA>, RepositoryFactory<IMyRepositoryA>>(); services.AddSingleton<IRepositoryFactory<IMyRepositoryB>, RepositoryFactory<IMyRepositoryB>>(); etc.

  • and of course, thanks for the library!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LittleColincommented, May 31, 2018

Yes it was the latter - scan and register open generic types. But as you point out, that is not necessary if registering open generics using the syntax you showed. I wasn’t aware this was possible so thanks for your help on this - feel free to close the issue, it’s no longer an issue for me.

Thanks again

1reaction
khellangcommented, May 23, 2018

Oh, are you asking if you can register open generics? I.e.

services.AddSingleton(typeof(IRepositoryFactory<>), typeof(RepositoryFactory<>))

That’s possible without this library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced TypeScript Techniques: Generics, Decorators, ...
Generics are a way to create reusable code that can work with a variety of different types. They allow you to define a...
Read more >
Typescript Decorator with Generic Type
1 Answer. Decorators can't change the structure of the class, this limitation is by design. We can use mixins to achieve mutation of...
Read more >
Generic decorators - could they receive some default type ...
A decorator can receive arguments, by being defined as a function ... Generic decorators - could they receive some default type arguments?
Read more >
Generics - mypy 1.5.1 documentation
The built-in collection classes are generic classes. Generic types have one or more type parameters, which can be arbitrary types. For example, dict[int,...
Read more >
Documentation - Decorators
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found