예제 #1
0
        private void GetArgsAndInitComboBoxes()
        {
            BindingDef def = null;

            foreach (ComboBox cb in _comboxes.Keys)
            {
                def = _comboxes[cb];
                cb.Items.Clear();
                Dictionary <IAction, PropertyInfo[]> atts = _bindingEnvironment.QueryCompatibleProperty(_action, def.BindingAttribute, def.PropertyInfo);
                if (atts != null && atts.Count > 0)
                {
                    foreach (IAction act in atts.Keys)
                    {
                        PropertyInfo[] ps = atts[act];
                        if (ps == null || ps.Length == 0)
                        {
                            continue;
                        }
                        foreach (PropertyInfo p in ps)
                        {
                            BindingAttribute    ba     = ArgBindingHelper.GetBingdingAttribute(p.Name, act);
                            BindingScriptObject script = new BindingScriptObject(act, ba, p, def.PropertyInfo);
                            cb.Items.Add(script);
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Task.cs 프로젝트: configare/hispeed
 /// <summary>
 /// 绑定引用到Action
 /// </summary>
 /// <param name="arg">参数绑定定义对象</param>
 /// <param name="act">待绑定Action</param>
 /// <param name="actType">待绑定Action的具体类型</param>
 /// <returns>是否绑定成功</returns>
 private bool BindRefValueToAction(ActionArg arg, IAction act, Type actType)
 {
     try
     {
         //从已执行队列中发现参数来源Action
         IAction resAction = FindAction(arg.RefActionId);
         if (resAction == null)
         {
             if ((act as ActionBase).Id != arg.RefActionId)
             {
                 LogError(string.Format(errRefActionLost2, act.Name, arg.Name));
                 return(false);
             }
             else
             {
                 resAction = act;
             }
         }
         //获取源Action的BingdingAttribute 元数据                                                        Filename         QualityChecker
         BindingAttribute resBindingAtt = ArgBindingHelper.GetBingdingAttribute(arg.RefName, resAction);
         if (resBindingAtt == null)
         {
             LogError(string.Format(errBindingAttributeLost4, act.Name, arg.Name, resAction.Name, arg.RefName));
             return(false);
         }
         //获取目标Action的BingdingAttribute                                                                 Filename    SpecialRegionChecker
         BindingAttribute desBindingAtt = ArgBindingHelper.GetBingdingAttribute(arg.Name, act);
         if (desBindingAtt == null)
         {
             LogError(string.Format(errBindingAttributeLost4, act.Name, arg.Name, act.Name, arg.Name));
             return(false);
         }
         //绑定参数语义类型是否兼容,泛型关系暂未做处理
         if (!resBindingAtt.SemanticType.Equals(desBindingAtt.SemanticType))
         {
             LogError(string.Format(errArgTypeNotMatch4, act.Name, arg.Name, resAction.Name, arg.RefName));
         }
         //从源Action获取绑定值                               Action1:QualityChecker.Filename
         object refValue = resAction.GetType().InvokeMember(arg.RefName, BindingFlags.GetProperty, null, resAction, null);
         //将获取到的绑定值绑定到目标Action的参数arg.Name        Action2:SpecialRegionChecker.Filename
         actType.InvokeMember(arg.Name, BindingFlags.SetProperty, null, act, new object[] { refValue });
         return(true);
     }
     catch (Exception ex)
     {
         LogError(string.Format(errBindArgFaileExceptionAtNextLog2, act.Name, arg.Name));
         LogException(ex);
         return(false);
     }
 }