You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by hammett <ha...@uol.com.br> on 2004/08/29 13:01:19 UTC

Re: Success! Avalaon/Castle Configuration

Hey Sasha,

I'm back to Brazil and already working on the issues you've raised. Thanks
for your time on it.


Cheerio!

----- Original Message ----- 
From: "scikusa" <sc...@yahoo.com>
To: "hammett" <ha...@uol.com.br>
Sent: Sunday, August 15, 2004 11:37 AM
Subject: Success! Avalaon/Castle Configuration


Hi Hammett,

I did more digginh and now understand what
IConfigurationSectionHandler does. It is used by the
System.Configuration when calling
"ConfigurationSettings.GetConfig(mySection)" to return
our custom configuration data object. The handler must
be specified in the App.config file under its own
section/group.

With regards to
Apache.Avalon.Framework.DefaultConfigurationSectionHandler
all I did was to declare it in my App.config as the
class to handle my section.

Then I found out that DefaultConfigurationManager (in
Apache.Avalon.Castle.MicroKernel.Subsystems.Configuration.Default)
doesn't load the configuration from the App.config
automatically, it just retrieves it from its own
private m_name2Config Hashtable - if it has been
loaded manually.

So thats what I did:

<----------------START---------------->
container = new DefaultKernel();

DefaultConfigurationManager cfgMgr =
(DefaultConfigurationManager)
container.GetSubsystem(KernelConstants.CONFIGURATION);

IConfiguration config = (IConfiguration)
ConfigurationSettings.GetConfig("SubscriptionManager");

cfgMgr.Add("SubscriptionManager", config);

container.AddComponent("SubscriptionManager",
typeof(ISubscriptionManager),
typeof(SubscriptionManager));

IHandler handler = container["SubscriptionManager"];

ISubscriptionManager service = handler.Resolve() as
ISubscriptionManager;

<----------------END---------------->

So now when "handler.Resolve()" is called my
"SubscriptionManager" component (which implements
IConfigurable) is given its configuration from the
app.config file.

All without writing any code! Ok, now we're getting
somewhere.

Is there a way that the DefaultConfigurationManager
can load the App.config file automatically?

Regards,
Sasha





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org