开发者

String format for Castle DictionaryAdapter

开发者 https://www.devze.com 2022-12-12 07:00 出处:网络
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 ):

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.con开发者_如何学运维fig

<?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 ?


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

See the PhoneConverter sample in the tests.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号