Hi,

I'm using the dictionary adapter as described in this blog post:

http://kozmic.net/2013/11/21/on-strongly-typed-application-settings-with-castle-dictionaryadapter/

for getting app setting dependencies.

I have 2 attributes defined:

AppSettingsFromConfigAttribute - for holding a keyprefix

AppSettingsBehavior : KeyPrefixAttribute, IDictionaryPropertyGetter, 
IPropertyDescriptorInitializer

which is a carbon copy of the AppSettingsAttribute attribute class in the 
blog post.

This is the registration:

Configure(component => component.UsingFactoryMethod(
                    () =>
                    {
                        var attrib = 
(AppSettingsFromConfigAttribute)Attribute.GetCustomAttribute(component.Implementation,
 
typeof(AppSettingsFromConfigAttribute));

                        var prop = new PropertyDescriptor();

                        prop.AddBehavior(new 
AppSettingsBehavior(attrib.KeyPrefix));

                        return 
configFactory.GetAdapter(component.Implementation, new 
NameValueCollectionAdapter(ConfigurationManager.AppSettings), prop);
                    })));

So i use my custom attribute to avoid dependencies to Castle.Core 
throughout my codebase, but try and add the same behavior at runtime 
through the registration. This is working, the keyprefix part - but not the 
fetch part. This fails only on first use, not on construction.

If i use the AppSettingsBehavior statically on the interface, it works 
correctly, fetches and fails on construction. So where am i going wrong in 
adding behavior to the dictionary adapter?

Best,
Vivek

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to