Comments (3)
Iām using a fairly substantial modification of Hypodermic (for supporting Unreal Engine types) and I added a block for such resolutions. Basically anything registered with an alias will refuse to resolve the actual type unless asSelf() has also been used.
The rewrite makes it a bit tricky to supply a patch but it basically tracks any aliased types and rejects them in resolveIfCanBeRegistered, which is where the concrete type otherwise would be doubly registered.
Iām currently on vacation but I can supply more details in August.
from hypodermic.
@badiozam hey, as @judgeaxl stated, you can use asSelf()
on a registration to tell Hypodermic that you want your concrete type to be resolvable as well. So if I use your sample it goes like this:
Hypodermic::ContainerBuilder builder;
builder.registerType< ConcreteClass >().as< InterfaceClass >().asSelf().singleInstance();
...
auto container = builder.build();
...
auto singleton_interface_ref = container->resolve< InterfaceClass >();
auto singleton_concrete_ref = container->resolve< ConcreteClass >();
assert(singleton_interface_ref == singleton_concrete_ref); // Will pass
You can have a look at the wiki to discover more features.
Cheers
from hypodermic.
@badiozam I am closing this issue. Feel free to keep asking for help.
from hypodermic.
Related Issues (20)
- GUN C++ 4.7.3 Compiler error HOT 1
- Resolve other than shared_ptr (e.g. unique_ptr) HOT 5
- Current syntax for register factory with arguments HOT 5
- Pass parameters to register type HOT 1
- Resolve a chain of instantiate of explicit dependencies name?
- Compile errors: multiple definition of boost::*
- static assertion failed: TArg should be a complete type HOT 5
- [FeatureRequest] Fluent lifetime management HOT 1
- Autowiring of factory methods HOT 2
- Question: register two interfaces for same concrete class HOT 2
- Fail to build in window boost1.7 gcc9
- Bug: interface is resolved twice from nested container if they are added as both .as<interface>() and .asSelf() HOT 2
- Bug: singleInstance not working as expected when resolving from nested containers HOT 2
- How to inject a factory for named instances? HOT 3
- Is it possible to specify the dependency explicitly while resolving HOT 4
- Issue when resolving same types in different shared libraries HOT 1
- ContainerBuilder doesn't have a virtual destructor HOT 1
- Hypodermic 2.5.3 won't link with Boost
- Is there a version without boost HOT 5
- Alternatives to `std::make_shared` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hypodermic.