Thanks for the advice, Krzysztof

Jorge

On Apr 14, 12:56 pm, Krzysztof Koźmic <[email protected]>
wrote:
> 1. Don't use custom activator.
> 2. Specify service overrides for dependencies you want to use
> non-default components for (for the remaining ones the default
> components will be used)
>
> On 2010-04-14 17:53, Jorge Rowies wrote:
>
> > Krzysztof, I'm probably doing something wrong, because I am not yet
> > familiar with Castle.
>
> > What I want to do, first of all, is to disable Property auto-wiring.
> > I'm doing it with a custom activator using what Roelof Blom proposed
> > in the last post of this thread:
> >http://groups.google.com/group/castle-project-users/browse_thread/thr...
>
> > The other thing I'm trying to do, is to wire a non-default IMyService
> > implementation into the property MyService of ProductController, as
> > far as I know, to accomplish this I have to use ServiceOverrides
> > (maybe this is where I'm doing something wrong)
>
> > thanks
> > Jorge
>
> > On 14 abr, 03:01, Krzysztof Koźmic<[email protected]>  wrote:
>
> >> Jorge,
>
> >> I've got a feeling we're not on the same page here.
> >> If all you want is to be explicit you want a non-default IMyService
> >> injected into your ProductController than just doing serviceoverride
> >> with default activator should do it.
>
> >> Why are you using custom activator again?
>
> >> Krzysztof
>
> >> On 2010-04-13 16:50, jorge.rowies wrote:
>
> >>> First of all, I feel that I have to make clear one point, I am a
> >>> completely newbie at Castle, so please forgive me for all the mistakes
> >>> I could make in the following sentences (and for my english) :P
>
> >>> I am currently working on a migration of a bunch of configurations
> >>> made in spring.net (xml) to Castle using Fluent API, and the code that
> >>> I am wiring is "almost" legacy code, so I have to lower to a minimum
> >>> the amount of changes to the existing code in this process of
> >>> migrating from spring.net to castle.
>
> >>> @John
> >>> About using DoNotWire attribute, I can't go that way for two reasons,
> >>> first, because of the legacy code issue I mentioned before and,
> >>> second, because that will "tie" my code to Castle.
>
> >>> @Krzysztof
> >>> I'm not sure if I understand, I have properties that I want to wire by
> >>> using ServiceOverride, like this:
>
> >>> container.Register(
> >>>       Component.For<IMyService>()
> >>>           .ImplementedBy<MyServiceImpl>()
> >>>           .Named("myservice.default"),
> >>>       Component.For<IMyService>()
> >>>           .ImplementedBy<OtherServiceImpl>()
> >>>           .Named("myservice.alternative"),
>
> >>>       Component.For<ProductController>()
> >>>           .ServiceOverrides(ServiceOverride.ForProp(p =>
> >>> p.MyService).Eq("myservice.alternative")) //<-- here I am using this
> >>> extensionshttp://using.castleproject.org/display/IoC/Strongly+Typed+property+wi...
> >>> );
>
> >>> public class ProductController
> >>> {
> >>>       public IMyService MyService {get;set;}
> >>>       public ProductController()
> >>>       {
> >>>       }
> >>> }
>
> >>> But I don't want MyService property to be auto-wired.
>
> >>> If I remove the setter of MyService property, this could be achieved?
>
> >>> Thanks a lot John and Krzysztof
> >>> Jorge
>
> >>> On 12 abr, 19:08, Krzysztof Koźmic<[email protected]>    wrote:
>
> >>>> why do you have the properties settable if you don't want to set them?
>
> >>>> 2010/4/12 jorge.rowies<[email protected]>:
>
> >>>>> Hello, Roelof Blom said in the last post of this thread:
>
> >>>>>http://groups.google.com/group/castle-project-users/browse_thread/thr...
>
> >>>>> That one way of disabling property auto-wiring could be achieved with
> >>>>> something like this:
>
> >>>>> container.Register(Component
> >>>>>    .For(impl) .LifeStyle.Transient)
> >>>>>    .Activator<MyModelActivator>()
>
> >>>>> class MyModelActivator: DefaultComponentActivator
> >>>>> {
> >>>>>      protected override void SetUpProperties(object instance,
> >>>>> CreationContext
> >>>>> context)
> >>>>>      {
> >>>>>          // Do not auto-wire
> >>>>>      }
>
> >>>>> }
>
> >>>>> Which worked great for me, but now I am having problems using
> >>>>> ServiceOverrides to set dependencies on a property, and I think it is
> >>>>> because of this custom activator.
>
> >>>>> Is there any way to prevent property auto wiring and still be able to
> >>>>> use ServiceOverrides?
>
> >>>>> Thanks a lot
>
> >>>>> --
> >>>>> You received this message because you are subscribed to the Google 
> >>>>> Groups "Castle Project Users" group.
> >>>>> To post to this group, send email to 
> >>>>> [email protected].
> >>>>> To unsubscribe from this group, send email to 
> >>>>> [email protected].
> >>>>> For more options, visit this group 
> >>>>> athttp://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to