zoukankan      html  css  js  c++  java
  • 实际一个多态(或弱类型)ConfigurationElementCollection

    不知道你们有没有过这样的一个需求:

         假如我要实现一个像Windows的任务计划一样的工具。我支持按天执行,或按月执行,甚至我还直接按每个星期几来执行。好吧,做这样一个东西不难。现在我希望把这些运行信息存在配置文件中。那么配置文件可能是这样的结构

      

      <scheduleServiceSection>
        <schedules>
          <add name ="DaySchedule" 
               days="1" startDateTime="2012/11/30 11:59:59" endDateTime="2013/11/30 11:59:59" runTime="11:59:59" >
          </add>
        
    
          <add name ="MonthSchedule" 
         months="1" runMonths="1,2,3,4,5,6,7,8,9,10,11,12"
               runDays="1,2,3,4,5"
               startDateTime="2012/11/30 11:59:59" endDateTime="2013/11/30 11:59:59" runTime="11:59:59" >
          </add>
    
          <add name ="WeekSchedule"
         weeks="1" runWeekDays="0,1,2,3,4,5,6"
         startDateTime="2012/11/30 11:59:59" endDateTime="2013/11/30 11:59:59" runTime="11:59:59" >
    
          </add>
        </schedules>
      </scheduleServiceSection>

     .net 自带的配置集合 ConfigurationElementCollection,只能包含一种类型的ConfigurationElement。不能实现像上面那种WeekSchedule比DaySchedule多一些属性或少一些属性。

    解决办法:

    https://github.com/Yunanw/CSSnippet/tree/master/PolyConfigCollection

  • 相关阅读:
    python 三方面库整理
    windows MYSQL 安装及修改root密码
    TCP 套叠字
    自动化谷歌浏览驱动
    python os
    python 协程
    python GIL :全局解释器
    python 多进程
    python 多线程
    python 3 往Excel 中的写入内容但不覆盖原内容
  • 原文地址:https://www.cnblogs.com/listhome/p/2807625.html
Copyright © 2011-2022 走看看