avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hammett" <hamm...@uol.com.br>
Subject Re: Success! Avalaon/Castle Configuration
Date Sun, 29 Aug 2004 11:01:19 GMT
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" <scikusa@yahoo.com>
To: "hammett" <hammett@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


Mime
View raw message