代码之家  ›  专栏  ›  技术社区  ›  alexandrul

Castle DictionaryAdapter的字符串格式

  •  0
  • alexandrul  · 技术社区  · 15 年前

    我正在使用Castle DictionaryAdapter,以便从 App.CONFIG 作为接口(基于 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>
    

    是否可以将DictionaryAdapter配置为使用自定义字符串格式,如 “YYYYMMD HDHMM” 用于转换存储在 App.CONFIG ?

    1 回复  |  直到 15 年前
        1
  •  2
  •   mynkow    14 年前

    是的,您可以定义自己的类型转换器,并通过应用类型转换器属性来使用它。

    PhoneConverter sample in the tests .