zoukankan      html  css  js  c++  java
  • WF Rules对于迭代的实现

    因为WF Rules 是针对Instance而非Type,也就是说针对单个对象而不是针对于集合,所以对于集合的规则来说,就显得实现起来非常麻烦,首先需要定义额外的属性,另外需要定义多个规则,而且要精心设计,才能实现迭代。典型的实现如下:
      Rule 1 (Priority = 2)  //Always execute this rule once to create the enumerator.
         IF 1==1
         THEN this.enumerator = this.myCollection.GetEnumerator()
      Rule2 (Priority = 1)
         IF this.enumerator.MoveNext()
         THEN this.currentInstance = this.enumerator.Current
     Rules 3-N (Priority = 0)
          .... //Additional rules written against this.currentInstance
      Rule N+1 (Priority = -1)
               // can be any condition as long as it is evaluated every time;
               // this.currentInstance will be evaluated each time this.currentInstance changes, whereas
                // "1==1" would only be evaluated once.
           IF this.currentInstance == this.currentInstance  
           THEN ...
                Update("this/enumerator") //this will cause Rule 2 to be reevaluated
            ELSE ...
                Update("this/enumerator")

    这种模式仅仅能够实现一个Collection,若存在多个collection或者存在层次机构的Collection的话,必须依次实现多个Collection的迭代。

    可见这是非常麻烦的。因为WF并非是基于Rete算法的实现(其基于类型和集合,而非Instance),所以只能这么麻烦了,期待WF的下一个版本吧。
  • 相关阅读:
    vue 前端框架 (二) 表格增加搜索
    vue 前端框架
    数据结构-树的基本操作
    linux的串口驱动分析
    TTY驱动程序架构
    linux MTD系统解析(转)
    DM9000网卡的基本工作原理
    ok6410的LCD裸机范例
    ok6410的DMA裸机总结
    ok6410串口裸机总结
  • 原文地址:https://www.cnblogs.com/headchen/p/827966.html
Copyright © 2011-2022 走看看