you want to pass the actual value, not the property reference.
Parameter.ForKey("password").Eq("SomePassword")

here is an example taken from rhino.esb. here an array of services are
registered instead of a single property value. the concept should be
similar.
protected override void RegisterComponents()
{
        Kernel.Register(
                Component.For<IDeploymentAction>()
                        .ImplementedBy<CreateLogQueueAction>(),
                Component.For<IDeploymentAction>()
                        .ImplementedBy<CreateQueuesAction>(),
                Component.For<IServiceBus, IStartableServiceBus>()
                        .ImplementedBy<DefaultServiceBus>()
                        .LifeStyle.Is(LifestyleType.Singleton)
                        .DependsOn(new
                        {
                                messageOwners = messageOwners.ToArray(),
                        })
                        
.Parameters(Parameter.ForKey("modules").Eq(CreateModuleConfigurationNode())
                        )
                );
}

private IConfiguration CreateModuleConfigurationNode()
{
        var config = new MutableConfiguration("array");
        foreach (Type type in messageModules)
        {
                config.CreateChild("item", "${" + type.FullName + "}");
        }
        return config;
}

another idea: get access to the configuration store, get the
properties node and pull the password_property value from the
configuration store.

I like to use the dependson() method to register constants. i find
it's cleaner. example:
class Foo
{
   public int Number {get;set;}

   Foo(string text)
   {
   }
}

Component.For<Foo>().DependsOn(new{text = "hi", Number = 1})


On Oct 15, 1:47 pm, Symon Rottem <[email protected]> wrote:
> Sure thing.  It's a bit of a contrived example, but here goes:
>
> I want to have some properties registered in my <castle> section in my
> web.config:
>
>   <configSections>
>     <section name="castle"
> type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,
> Castle.Windsor"/>
>   </configSections>
>
>   <castle>
>     <properties>
>       <password_property>SomePassword<password_property>
>     </properties>
>   </castle>
>
> And then use them when registering a component fluently:
>
> windsorContainer = new WindsorContainer();
> windsorContainer.Install(Configuration.FromAppConfig());
>
> windsorContainer.Register(
> Component
> .For<SomeComponent>()
>  .Parameters(Parameter.ForKey("password").Eq("#{password_property}"))
> );
>
> Could be I'm doing it all wrong, but what I get passed into the "password"
> parameter in the constructor of my SomeComponent instance is the value
> "#{password_property}" rather than "SomePassword" as I sexpected.
>
> What am I doing wrong?
>
> Cheers,
>
> Symon.
>
> Symon Rottemhttp://blog.symbiotic-development.com
>
> On Fri, Oct 15, 2010 at 7:20 PM, Jason Meckley <[email protected]>wrote:
>
> > yes you can, there are multiple ways to configure components. first
> > get the values from the xml file. that is external to windsor. then
> > you can use the DependsOn fluent method or ServiceOverride or
> > Property.For().Eq() to configure the component. there may be more
> > options as well but these are ones I'm aware of.
>
> > if you provide a code sample of what you want to do we may be able to
> > help.
>
> > On Oct 15, 12:56 pm, João Bragança <[email protected]> wrote:
> > > It's an ugly solution, but what about loading the XML file in an
> > > xmldocument/xdocument and getting the properties that way?
>
> > > On Oct 15, 7:15 am, Symon Rottem <[email protected]> wrote:
>
> > > > Is it possible to use property reference notation (#{property}) in the
> > > > fluent API?
>
> > > > I want to use properties that are registered in XML to set values on
> > > > components registered via the API, but I don't seem to be having any
> > luck.
>
> > > > Cheers,
>
> > > > Symon.
>
> > > > Symon Rottemhttp://blog.symbiotic-development.com
>
> > --
> > 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]<castle-project-users%[email protected]>
> > .
> > 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 [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