using dictionary in castle windsor configuration?

295 views
Skip to first unread message

Scott_M

unread,
Jun 17, 2011, 12:14:42 PM6/17/11
to Castle Project Users
I am using a dictionary in castle windsor configuration to build an
authenticator factory. The dictionary key represents a URL and then
the object represents each specific authenticator service.

//config
<component id="AuthenticatorFactory" lifestyle="singleton"
service="Security.IAuthenticatorFactory, Security"
type="Security.AuthenticatorFactory, Security">
<parameters>
<authenticators>
<dictionary>
<entry key="https://smpc.acme.com/sts/sts.svc/
anonymoususer">${AnonymousUserAuthenticator}</entry>
<entry key="https://wcvpc-w7.acme.com/sts/sts.svc/
anonymoususer">${AnonymousUserAuthenticator}</entry>
<entry key="https://tkpc.acme.com/sts/sts.svc/
anonymoususer">${AnonymousUserAuthenticator}</entry>
</dictionary>
</authenticators>
</parameters>
</component>

//code
public class AuthenticatorFactory : IAuthenticatorFactory
{
private Dictionary<string, IAuthenticator> m_authenticators =
new Dictionary<string, IAuthenticator>();

public AuthenticatorFactory(Dictionary<string, IAuthenticator>
authenticators)
{
m_authenticators = authenticators;
}

public IAuthenticator GetAuthenticator(string url)
{
IAuthenticator retVal = null;

if (m_authenticators.ContainsKey(url))
{
retVal = m_authenticators[url.ToString()];
}

return retVal;
}
}

By default the dictionary appears to be case sensitive. Is there a
way to have castle construction a case insensitive dictionary?



scottm

Mauricio Scheffer

unread,
Jun 17, 2011, 2:42:33 PM6/17/11
to castle-pro...@googlegroups.com
You could write a type converter that puts data in a case-insensitive dictionary. 

--
You received this message because you are subscribed to the Google Groups "Castle Project Users" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en.


Krzysztof Koźmic

unread,
Jun 18, 2011, 6:58:39 AM6/18/11
to castle-pro...@googlegroups.com
I actually think that's a bug.
Everything else in Windsor is case insensitive... why that should be any different?

Krzysztof

Scott_M

unread,
Jun 18, 2011, 9:51:08 AM6/18/11
to castle-pro...@googlegroups.com
Ahhhh, good point..  

I found a quick / hacky around.  In my constructor I now take the castle provided dictionary and copy its contents to a non case sensitive dictionary and use the latter.






Reply all
Reply to author
Forward
0 new messages