Hello again.

Should have looked at the docs before sending the mail. it seems like
using the dependson method will do the trick:

 _container.Register(
                Component.For<RelatoriosDataContext>( )

.DependsOn(Property.ForKey("connection").Eq(ConfigurationManager.ConnectionStrings["ocorrencias"].ConnectionString))
                    .LifeStyle.Is( _lifeStyle ));

thanks.

On Tue, Feb 15, 2011 at 11:26 AM, Luis Abreu <[email protected]> wrote:
> Hello guys.
>
> Quick question: is there a way for me to specify the type of a
> parameter used during the registration of a component? My problem is
> that I have a component which relies on a datacontext derived class
> and the wizard generates two constructors with a single parameter
> which have the same name and different types:
>
> public RelatoriosDataContext(string connection) :
>                                base(connection, mappingSource)
>                {
>                        OnCreated();
>                }
>
>                public RelatoriosDataContext(System.Data.IDbConnection 
> connection) :
>                                base(connection, mappingSource)
>                {
>                        OnCreated();
>                }
>
> Currently, I'm using something like this to register this component:
>
>  _container.Register(
>                Component.For<RelatoriosDataContext>( )
>                    .Parameters(
>                        Parameter.ForKey( "connection" )
>                                 .Eq(
> ConfigurationManager.ConnectionStrings["ocorrencias"].ConnectionString
> ))
>                    .LifeStyle.Is( _lifeStyle ) );
>
>
> the problem is that castle is picking the wrong version of the
> constructor. Yes, I can rename the parameter in one of the
> constructors, but since they're generated by a wizard and I don't have
> any control over them, I'd like to know if I missed something and if
> there's a way for me to influence the constructor that gets picked.
>
> thanks.
>
> --
> Regards,
> Luis Abreu
>



-- 
Regards,
Luis Abreu

-- 
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