0

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 ?

Krzysztof Kozmic
  • 27,267
  • 12
  • 73
  • 115
alexandrul
  • 12,856
  • 13
  • 72
  • 99

1 Answers1

2

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

See the PhoneConverter sample in the tests.

mynkow
  • 4,408
  • 4
  • 38
  • 65
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275