Пример #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
 /// <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);
     }
 }
Пример #3
0
        public Dictionary <IAction, PropertyInfo[]> QueryCompatibleProperty(IAction action, BindingAttribute bindingAttribute, PropertyInfo propertyInfo)
        {
            if (_actionElements == null || _actionElements.Count == 0)
            {
                return(null);
            }
            Dictionary <IAction, PropertyInfo[]> atts = new Dictionary <IAction, PropertyInfo[]>();

            //
            foreach (ActionElement ele in _actionElements)
            {
                IAction act = ele.Action;
                if (act.Equals(action))
                {
                    continue;
                }
                Dictionary <PropertyInfo, BindingAttribute> ps = ArgBindingHelper.GetBindingProperties(act.GetType());
                List <PropertyInfo> infos = new List <PropertyInfo>();
                foreach (PropertyInfo info in ps.Keys)
                {
                    infos.Clear();
                    BindingAttribute ba = ps[info];
                    if (!bindingAttribute.SemanticType.Equals(ba.SemanticType))
                    {
                        continue;
                    }
                    if (!propertyInfo.PropertyType.Equals(info.PropertyType))
                    {
                        continue;
                    }
                    if (ba.Direction == enumBindingDirection.Input || ba.Direction == enumBindingDirection.None)
                    {
                        continue;
                    }
                    infos.Add(info);
                }
                if (infos.Count > 0)
                {
                    atts.Add(act, infos.ToArray());
                }
            }
            return(atts);
        }
Пример #4
0
        private void BuildControls()
        {
            Type type = _action.GetType();
            Dictionary <PropertyInfo, BindingAttribute> properites = ArgBindingHelper.GetBindingProperties(type);

            if (properites == null || properites.Count == 0)
            {
                return;
            }
            int top = 20;

            BindingPair[] pairs = null;
            if (_bindingEnvironment != null)
            {
                pairs = _bindingEnvironment.GetBindingPairs(_action);
            }
            foreach (PropertyInfo p in properites.Keys)
            {
                BindingAttribute att = properites[p];
                if (att.Direction == enumBindingDirection.None || att.Direction == enumBindingDirection.Output)
                {
                    continue;
                }
                top = CreateLabel(top, p, att);
                top = CreateInputControl(top, p, att, pairs);
            }
            foreach (Control c in panelTop.Controls)
            {
                if (c is ComboBox || c is ListBox)
                {
                    c.Anchor = c.Anchor | AnchorStyles.Right;
                }
                else if (c is Button)
                {
                    c.Anchor = AnchorStyles.Top | AnchorStyles.Right;
                }
            }
        }