Comments (4)
What you would do is to register a factory that returns the pointer initialized the way you want it to be using builder.registerInstanceFactory
. There's an example on the wiki: https://github.com/ybainier/Hypodermic/wiki/Registering-components#register-a-factory
from hypodermic.
We're aware of this feature, but it forces us to have to explicitly pass all the necessary parameters to the type (via context.resolve<>
) when constructing it.
Is there a way to instead change the default to something else other than std::make_shared
and benefit from the auto-wiring and just use registerType()
?
from hypodermic.
I see what you're getting at. I imagine it would be possible to add something like a .withDeleter(x)
when registering a type. That feels like the best fit to the existing API instead of replacing std::make_shared
wholesale. However, I'm not a maintainer and while I have dug very deep into this library for various reasons, I think it would probably take a bit of work to add it.
from hypodermic.
Actually, I looked back at the logic for resolving arguments automatically, and you'd have to provide both the deleter, and allocator, or a method that does both, so just .withDeleter
would not work.
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
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.