Hm, what do you mean by "using the other value"?

I replace a componenten for instance in the following scenario:

I have a WinForm app. The app works with Navigators,Views and Presenters. A
view may be a Navigator
by itself and handles Subviews, similar to the settings dialog in Visual
Studio. The Navigator to use
will be resolved from the container, also the Views,Subviews, Presenters and
other services etc.
The problem is now, that the user can select what kind of Navigator he wants
to use. Maybe
Explorer - like Navigator, Outlook like Navigator, Ribbon like Navigator and
so on. This means, there
are different implementations available for the service ISubNavigator. When
the user changes the preffered
Navigator, i remove the current ISubNavigator registration from the
container and register the newly
selected. This can be done during runtime by loading a new assembly or
selecting from exiting
implementations.

So, this is one situation where i use the register/remove methods. Maybe i
can do this in a completly
other way.
What did you mean by "no other component depends on it"? In case of a
Transient Lifestyle Service,
what components should depend on it?

2011/2/22 Krzysztof Koźmic <krzysztof.koz...@gmail.com>

>  Why would you replace a component instead of using the other value in the
> first  place?
>
> What do you mean by "the service is not available anymore"?
>
> K
>
>
> On 22/02/2011 11:17 AM, Belvasis wrote:
>
> I remove the component from the container for instance if i have to
> register a different implementation or configuration for a service
> during runtime or the service is not available anymore etc. and i thought
> remove/register would be an easy way to do that.
> In the current case i'm just a little confused because it ever worked
> without any problem, even with the current code. In the moment
> i call RemoveComponent, there is no other component that depends on it. But
> maybe i just can't see it.
> Anyway,i think in this case i can avoid the use of RemoveComponent by using
> a factory method instead.
>
>
>
> 2011/2/22 Krzysztof Koźmic <krzysztof.koz...@gmail.com>
>
>> That's how it works. RemoveComponent will only remove the component when
>> it's safe to do so, i.e. no other component depends on it.
>>
>> Why are you removing the component from the container?
>>
>> I'm asking because I want to remove that functionality from the container
>> altogether i.e. not allow to remove components once they are registered.
>>
>>
>>
>>
>> On 22/02/2011 9:52 AM, belvasis...@googlemail.com wrote:
>>
>>>  Hi,
>>>
>>> i have a behaviour that is very strange. I use the following to Remove a
>>> registration from the
>>> Container:
>>>
>>> if (m_pContainer.Kernel.HasComponent(i_strKey))
>>> {
>>> m_pContainer.Kernel.RemoveComponent(i_strKey);
>>> }
>>>
>>> This works in most cases. But sometimes HasComponent is true for the
>>> given i_strKey and i
>>> can see the component when inspecting the Kernel. After the call to
>>> RemoveComponent,
>>> the result is still the same...the component with the i_strKey name is
>>> sill there. So the next time
>>> i want to register a component with the i_strKey name, an exception is
>>> thrown.
>>> Has anyone an idea why this happens and what i can do?
>>>
>>> Thanks and Regards
>>>
>>>  B --
>>> You received this message because you are subscribed to the Google Groups
>>> "Castle Project Users" group.
>>> To post to this group, send email to
>>> castle-project-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> castle-project-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/castle-project-users?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Castle Project Users" group.
>> To post to this group, send email to
>> castle-project-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> castle-project-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/castle-project-users?hl=en.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To post to this group, send email to castle-project-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> castle-project-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To post to this group, send email to castle-project-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> castle-project-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to castle-project-users@googlegroups.com.
To unsubscribe from this group, send email to 
castle-project-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to