zoukankan      html  css  js  c++  java
  • WWF中Conditioned Activity Group的子Activity扩展CAG的WhenCondition属性代码解析

    通过三个地方实现这个功能:这样放入CAG中的Activity在设计期间能在属性窗口中看到WhenCondition属性

    1 CAG添加WhenCondition属性

    2 实现设计时扩展接口 IExtenderProvider ConditionPropertyProviderExtender

    3 ConditionedActivityGroupDesigner 关联Activity和扩展实现

    关于实现IExtenderProvider 的示例可参考文章

    部分代码如下:

    1
    [Designer(typeof(ConditionedActivityGroupDesigner), typeof(IDesigner)), ToolboxItem(typeof(ActivityToolboxItem)), SRDescription("ConstrainedGroupActivityDescription"), ToolboxBitmap(typeof(ConditionedActivityGroup), "Resources.cag.png"), ActivityValidator(typeof(ConditionedActivityGroupValidator)), SRCategory("Standard")]
    public sealed class ConditionedActivityGroup : CompositeActivity, IActivityEventListener<ActivityExecutionStatusChangedEventArgs>
    {
     ......
      
    public static readonly DependencyProperty WhenConditionProperty;
    }

    2

    [ProvideProperty("WhenCondition"typeof(Activity)), ProvideProperty("UnlessCondition"typeof(Activity))]
    internalsealedclassConditionPropertyProviderExtender : IExtenderProvider
    {
        public bool CanExtend(
    object extendee)
       {
           
    if ((extendee != this&& (extendeeisActivity))
            {
               
    return (((Activity) extendee).ParentisConditionedActivityGroup);
             }
             returnfalse;
        }
        
      
    public ActivityCondition   GetWhenCondition(Activity activity)   
       {       
           
    if (activity.ParentisConditionedActivityGroup)       
           {          
              
    return (activity.GetValue(ConditionedActivityGroup.WhenConditionProperty) asActivityCondition);        
            }       
           return null;   
        }                                                                                                          
        
      
    public  void  SetWhenCondition(Activity activity, ActivityCondition handler) 
       {
            
    if (activity.ParentisConditionedActivityGroup)      
             {            
                  activity.SetValue(ConditionedActivityGroup.WhenConditionProperty, handler);      
             }   
       }

     3

    //ConditionedActivityGroupDesigner的Initialize方法: 
    protected override void Initialize(Activity activity)
    {
          
    base.Initialize(activity);
          IExtenderListService service1 
    = (IExtenderListService) base.GetService(typeof(IExtenderListService));
          
    if (service1 != null)
          {
                
    bool flag1 = false;
                IExtenderProvider[] providerArray1 
    = service1.GetExtenderProviders();
                
    for (int num1 = 0; num1 < providerArray1.Length; num1++)
                {
                      IExtenderProvider provider1 
    = providerArray1[num1];
                      
    if (provider1.GetType() == typeof(ConditionPropertyProviderExtender))
                      {
                            flag1 
    = true;
                      }
                }
                
    if (!flag1)
                {
                      IExtenderProviderService service2 
    = (IExtenderProviderService) base.GetService(typeof(IExtenderProviderService));
                      
    if (service2 != null)
                      {
                            service2.AddExtenderProvider(
    new ConditionPropertyProviderExtender());
                      }
                }
          }
    }
  • 相关阅读:
    Python成长之路第一篇(4)_if,for,while条件语句
    Python成长之路第一篇(2)__初识列表和元组
    Python练习_更改配置文件(3)
    python练习_购物车(2)
    vue element ui 在父组件中控制子组件表单验证
    mysql find_in_set
    webstorm vuecli4 支持别名
    axios 长数字精度丢失问题
    vue element使用注意
    vue cli 查看webpack的配置
  • 原文地址:https://www.cnblogs.com/zhoujg/p/357072.html
Copyright © 2011-2022 走看看