Replies: 3 comments 10 replies
-
Hello, Names are not supposed to be unique, could you please paste here your configuration? I'd like to take a look at what goes wrong, thanks! |
Beta Was this translation helpful? Give feedback.
-
One other thing that I encountered, The resolve method has one overload without a name parameter and one with Since the name in the resolve method is not nullable, it forces me to write code like:
Is this intended as such? (Just an minor inconvenience) Context: My application has the option to register them via a name or without, hence there's this if now required on different places |
Beta Was this translation helpful? Give feedback.
-
I've released the fixes in |
Beta Was this translation helpful? Give feedback.
-
Hi
I'm investigating whether I can use stashbox as a replacement for the deprecated unity container and I have a "special" setup that I can't seem to get right with stashbox.
Context:
I have a type
Foo
, which has aBar
property of typeIBar
. Each type (Foo & IBar) is registered in the container. (Foo as singleton, and IBar as factory which resolves Foo and then calls the property to return)Now since I can have multiple Foos (and therefore also IBars), I used to register them with a name in Unity, So I was able later to decide when I resolved them, which one I get.
If I do the same with Stashbox, the result is that I get a InvalidCastException when resolving a named IBar. (Since Foo isn't implementing IBar directly). So somehow when resolving it returns the Foo object instead of calling my factory method (also when debugging it doesn't get hit)
So my question therefore is, is the construct of "name" in Stashbox different as such that they're unique? (E.g. registering a different type with the same name will result in a silent exception?) Or am I have I overlooked something 🤔
Beta Was this translation helpful? Give feedback.
All reactions