Example #1
0
        public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction)
        {
            LimnorProject        project = _class.Project;
            FormActionParameters dlgData = new FormActionParameters();

            if (_parameters == null)
            {
                _parameters = new ParameterValueCollection();
            }
            ActionMethod.ValidateParameterValues(_parameters);
            dlgData.SetScopeMethod(context);
            dlgData.LoadAction(this, _class.XmlData);
            DialogResult ret = dlgData.ShowDialog(caller);

            if (ret == DialogResult.OK)
            {
                _class.SaveAction(this, writer);
                ILimnorDesignPane pane = project.GetTypedData <ILimnorDesignPane>(_class.ClassId);
                if (pane != null)
                {
                    pane.OnActionChanged(_class.ClassId, this, isNewAction);
                    pane.OnNotifyChanges();
                }
                else
                {
                    DesignUtil.WriteToOutputWindowAndLog("Error editong ActionAssignInstance. ClassPointer [{0}] is not in design mode when creating an action. Please close the design pane and re-open it.", _class.ClassId);
                }
                return(true);
            }
            return(false);
        }
Example #2
0
        static public void ValidateParameterValues(ParameterValueCollection parameters, IList <IParameter> ps, IActionMethodPointer owner)
        {
            List <ParameterValue> pvs = new List <ParameterValue>();

            for (int i = 0; i < ps.Count; i++)
            {
                bool bFound = false;
                foreach (ParameterValue pv in parameters)
                {
                    if (string.Compare(ps[i].Name, pv.Name, StringComparison.Ordinal) == 0)
                    {
                        bFound = true;
                        DataTypePointer dp = ps[i] as DataTypePointer;
                        if (dp != null)
                        {
                            pv.SetDataType(dp);
                        }
                        else
                        {
                            pv.SetDataType(ps[i].ParameterLibType);
                        }
                        pvs.Add(pv);
                        break;
                    }
                }
                if (!bFound)
                {
                    ParameterValue p = owner.CreateDefaultParameterValue(i);
                    pvs.Add(p);
                }
            }
            parameters.Clear();
            parameters.AddRange(pvs);
        }
Example #3
0
 public void ValidateParameterValues()
 {
     if (_parameters == null)
     {
         _parameters = new ParameterValueCollection();
     }
     _mathExp.ValidateParameterValues(_parameters);
 }
Example #4
0
 public void SetParameterValue(string name, object value)
 {
     if (_parameters == null)
     {
         _parameters = new ParameterValueCollection();
     }
     _mathExp.ValidateParameterValues(_parameters);
     _parameters.SetParameterValue(name, value);
 }
Example #5
0
 public object GetParameterValue(string name)
 {
     if (_parameters == null)
     {
         _parameters = new ParameterValueCollection();
     }
     _mathExp.ValidateParameterValues(_parameters);
     return(_parameters.GetParameterValue(name));
 }
Example #6
0
        public object Clone(IActionContext act)
        {
            ParameterValueCollection obj = new ParameterValueCollection();

            foreach (ParameterValue pv in this)
            {
                obj.Add(pv.Clone(act));
            }
            return(obj);
        }
Example #7
0
 public void ValidateParameterValues()
 {
     if (_parameterValues == null)
     {
         _parameterValues = new ParameterValueCollection();
     }
     if (_methodPointer != null)
     {
         _methodPointer.ValidateParameterValues(_parameterValues);
     }
 }
Example #8
0
 public void SetParameterValue(string name, object value)
 {
     if (_parameterValues == null)
     {
         _parameterValues = new ParameterValueCollection();
     }
     if (_methodPointer != null)
     {
         _methodPointer.ValidateParameterValues(_parameterValues);
     }
     _parameterValues.SetParameterValue(name, value);
 }
Example #9
0
 public object GetParameterValue(string name)
 {
     if (_parameterValues == null)
     {
         _parameterValues = new ParameterValueCollection();
     }
     if (_methodPointer != null)
     {
         _methodPointer.ValidateParameterValues(_parameterValues);
     }
     return(_parameterValues.GetParameterValue(name));
 }
Example #10
0
        public ActionAssignInstance(ClassPointer owner)
        {
            _class               = owner;
            _actMethod           = new MethodCreateValue(this);
            _parameters          = new ParameterValueCollection();
            _valType             = new ParameterValue(this);
            _valType.Name        = Instance_Type;
            _valType.ParameterID = IntanceTypeId;
            ConstObjectPointer cop = new ConstObjectPointer(Instance_Type, typeof(Type));

            _valType.ConstantValue = cop;
            _valType.ConstantValue.SetOnValueChanged(onInstanceTypeChanged);
            _val             = new ParameterValue(this);
            _val.ParameterID = IntanceValueId;
            _val.Name        = Instance_Value;
            _parameters.Add(_valType);
            _parameters.Add(_val);
        }
Example #11
0
        public virtual IAction CreateNewCopy()
        {
            ActionExecMath a = (ActionExecMath)Activator.CreateInstance(this.GetType(), _class);

            a._actId   = (UInt32)(Guid.NewGuid().GetHashCode());
            a._asLocal = _asLocal;
            a._desc    = _desc;
            if (_mathExp != null)
            {
                a._mathExp = (MathExpMethod)_mathExp.Clone();
            }
            if (string.IsNullOrEmpty(_name))
            {
                a._name = "Action" + Guid.NewGuid().GetHashCode().ToString("x");
            }
            else
            {
                if (_name.Length > 30)
                {
                    a._name = _name.Substring(0, 30) + Guid.NewGuid().GetHashCode().ToString("x");
                }
                else
                {
                    a._name = _name + "_" + Guid.NewGuid().GetHashCode().ToString("x");
                }
            }
            a.ScopeMethodId = ScopeMethodId;
            a.SubScopeId    = SubScopeId;
            if (_parameters != null)
            {
                ParameterValueCollection ps = new ParameterValueCollection();
                foreach (ParameterValue pv in _parameters)
                {
                    pv.SetCloneOwner(a);
                    ps.Add((ParameterValue)pv.Clone());
                }
                a._parameters = ps;
            }
            return(a);
        }
Example #12
0
        static public void ValidateParameterValues(ParameterValueCollection parameters, Type[] ps, IActionMethodPointer owner)
        {
            List <ParameterValue> pvs = new List <ParameterValue>();

            if (ps != null)
            {
                for (int i = 0; i < ps.Length; i++)
                {
                    bool bFound = false;
                    if (i < parameters.Count && parameters[i] != null)
                    {
                        if (parameters[i].ParameterLibType != null)
                        {
                            if (parameters[i].ValueType == EnumValueType.ConstantValue && ps[i].IsAssignableFrom(parameters[i].ParameterLibType))
                            {
                                bFound = true;
                                parameters[i].SetDataType(ps[i]);
                                pvs.Add(parameters[i]);
                            }
                            else
                            {
                                bFound = true;
                                pvs.Add(parameters[i]);
                            }
                        }
                    }
                    if (!bFound)
                    {
                        ParameterValue p = owner.CreateDefaultParameterValue(i);
                        if (p != null)
                        {
                            pvs.Add(p);
                        }
                    }
                }
            }
            parameters.Clear();
            parameters.AddRange(pvs);
        }
 public void ValidateParameterValues(ParameterValueCollection parameterValues)
 {
     parameterValues.Clear();
 }
Example #14
0
        public void Execute(List <ParameterClass> eventParameters)
        {
            MethodPointer mp  = (MethodPointer)ActionMethod;
            MethodBase    mif = mp.MethodDef;

            ParameterInfo[] pifs = mp.Info;
            object[]        vs   = new object[mp.ParameterCount];
            if (_parameterValues == null)
            {
                _parameterValues = new ParameterValueCollection();
            }
            mp.ValidateParameterValues(_parameterValues);
            for (int k = 0; k < mp.ParameterCount; k++)
            {
                vs[k] = null;
                IEventParameter iep = _parameterValues[k].AsEventParameter();
                if (iep != null)
                {
                    if (eventParameters != null)
                    {
                        foreach (ParameterClass p in eventParameters)
                        {
                            if (iep.IsSameParameter(p))
                            {
                                vs[k] = p.ObjectInstance;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    vs[k] = _parameterValues[k].ObjectInstance;
                }
                if (vs[k] != null)
                {
                    if (!pifs[k].ParameterType.Equals(vs[k].GetType()))
                    {
                        vs[k] = ValueTypeUtil.ConvertValueByType(pifs[k].ParameterType, vs[k]);
                    }
                }
            }
            object ret;

            if (mif.IsStatic)
            {
                ret = mif.Invoke(null, vs);
            }
            else
            {
                ret = mif.Invoke(mp.ObjectInstance, vs);
            }
            MethodInfo minfo = mif as MethodInfo;

            if (minfo != null)
            {
                if (!typeof(void).Equals(minfo.ReturnType))
                {
                    ReturnValue = ret;
                }
            }
        }
Example #15
0
 public void ValidateParameterValues(ParameterValueCollection parameterValues)
 {
 }