views:

35

answers:

1

I'm using Castle DictionaryAdapter in order to get the application settings from the app.config as an interface ( based on Getting rid of strings (3): take your app settings to the next level ):

public interface ISettings {
  int MaxUsers { get; }
  string FeedbackMail { get; }
  DateTime LastUserLogin { get; }
}

app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="MaxUsers" value="20"/>
    <add key="FeedbackMail" value="foo@localhost"/>
    <add key="LastUserLogin" value="2009-06-15T13:45:30.0900000"/>
  </appSettings>
</configuration>

Is it possible to configure DictionaryAdapter to use a custom string format like "yyyyMMdd-HHmm" for converting the value stored in app.config ?

+2  A: 

Yes, you can define your own TypeConverter and use it by applying the TypeConverter attribute.

See the PhoneConverter sample in the tests.

Mauricio Scheffer
Thank you, will give it a try.
alexandrul