public ProgramInPort CreateInport()
 {
     if (_entity != null && _entity.ProgEntity != null && _entity.CanAddInputs)
     {
         IDataSelectionControl dlg = MathNode.GetPropertySelector(
             XmlSerialization.GetProjectGuid(_xmlNode.OwnerDocument),
             XmlSerialization.GetRootComponentId(_xmlNode),
             _entity.ProgEntity.OwnerObject,
             EnumPropAccessType.CanWrite);
         if (((Form)dlg).ShowDialog(this.FindForm()) == DialogResult.OK)
         {
             ObjectRef v = dlg.UITypeEditorSelectedValue as ObjectRef;
             if (v != null)
             {
                 ProgramInPort pp = new ProgramInPort(_entity.ProgEntity);
                 pp.PortProperty = v;
                 //add to collection
                 _entity.ProgEntity.AddInport(pp);
                 //setup
                 this.Parent.Controls.Add(pp);
                 pp.Owner = this;
                 pp.CheckCreatePreviousNode();
                 this.Parent.Controls.Add((Control)pp.PrevNode);
                 pp.CreateBackwardLine();
                 pp.Label.Text = v.localName;
                 ((MathNodeVariable)(((DrawingVariable)(pp.Label)).Variable.MathExpression[0])).VariableName = v.localName;
                 return(pp);
             }
         }
     }
     return(null);
 }
        public string CreatePhpScript(object portSelection, StringCollection method)
        {
            string ce = CreatePhpScript(method);

            if (_castTo != null)
            {
                IProgramPort p = portSelection as IProgramPort;
                if (p != null)
                {
                    ObjectRef prop = p.PortProperty;
                    if (prop != null)
                    {
                        StringCollection props = new StringCollection();
                        while (true)
                        {
                            props.Add(prop.localName);
                            prop = prop.Owner;
                            if (prop == null)
                            {
                                break;
                            }
                            if (prop.IsSameType(_castTo.EntityType))
                            {
                                break;
                            }
                        }
                        for (int i = props.Count - 1; i >= 0; i--)
                        {
                            ce = string.Format(CultureInfo.InvariantCulture, "{0}->{1}", ce, props[i]);
                        }
                    }
                }
            }
            return(ce);
        }
 public MethodRef(ObjectRef owner, string name, int id, ParameterDef[] parameters, RaisDataType returnType)
 {
     _methodOwnerObjectRef = owner;
     _methodName           = name;
     _methodId             = id;
     _parameters           = parameters;
     _retType = returnType;
 }
Beispiel #4
0
        public override void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            base.OnReadFromXmlNode(serializer, node);
            XmlNode nd = node.SelectSingleNode(ProgramEntity.XML_PortProperty);

            if (nd != null)
            {
                _property = (ObjectRef)XmlSerialization.ReadFromXmlNode(serializer, nd, this);
                ((MathNodeVariable)(this._label.Variable.MathExpression[0])).VariableName = _property.localName;
            }
        }
        public virtual void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            _devType = (ObjectRef)XmlSerialization.ReadFromChildXmlNode(serializer, node, XmlSerialization.XML_TYPE, new object[] { null });
            XmlNode child = node.SelectSingleNode(XmlSerialization.LIBTYPE);

            if (child != null)
            {
                _libType = XmlUtility.XmlUtil.GetLibTypeAttribute(child);
            }
            _desc = XmlSerialization.ReadStringValueFromChildNode(node, XmlSerialization.XML_DESCRIPT);
            _name = XmlSerialization.GetAttribute(node, XmlSerialization.XMLATT_NAME);
        }
Beispiel #6
0
        public override void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            base.OnReadFromXmlNode(serializer, node);
            _linkType = (EnumDataFlowType)XmlSerialization.GetAttributeEnum(node, XmlSerialization.XMLATT_DataLinkType, typeof(EnumDataFlowType));
            XmlNode nd = node.SelectSingleNode(ProgramEntity.XML_PortProperty);

            if (nd != null)
            {
                _property = (ObjectRef)XmlSerialization.ReadFromXmlNode(serializer, nd, this);
                ((MathNodeVariable)(this._label.Variable.MathExpression[0])).VariableName = _property.localName;
            }
        }
Beispiel #7
0
        /// <summary>
        /// when it is used as a data type, determine whether two objects are of the same type
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public bool IsSameType(ObjectRef obj)
        {
            if (this.Type == obj.Type)
            {
                switch (this.Type)
                {
                case ObjectRefType.Argv:
                    return(this.localName == obj.localName);

                case ObjectRefType.XPath:
                    return(this.localName == obj.localName);
                }
            }
            return(false);
        }
Beispiel #8
0
        public object Clone()
        {
            ObjectRef obj = new ObjectRef(_xpathNode);

            obj.Type = _type;
            obj.Name = _name;
            if (_owner != null)
            {
                obj.Owner = (ObjectRef)_owner.Clone();
            }
            if (_value != null)
            {
                obj.Value = (Data)_value.Clone();
            }
            return(obj);
        }
        public void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            XmlNode methodXmlNode = null;

            _methodName           = XmlSerialization.GetAttribute(node, XmlSerialization.XMLATT_NAME);
            _methodId             = XmlSerialization.GetAttributeInt(node, XmlSerialization.XMLATT_ID);
            _methodOwnerObjectRef = (ObjectRef)XmlSerialization.ReadFromChildXmlNode(serializer, node, XmlSerialization.XML_METHODOWNER, new object[] { null });
            if (_methodId != 0)
            {
                methodXmlNode = node.OwnerDocument.SelectSingleNode(
                    XmlSerialization.FormatString("//{0}[@{1}='{2}']", XmlSerialization.XML_METHOD, XmlSerialization.XMLATT_ID, _methodId));
            }
            if (methodXmlNode == null)
            {
                if (_methodId != 0)
                {
                    throw new MathException("Method {0} not found", _methodId);
                }
                _retType = (RaisDataType)XmlSerialization.ReadFromChildXmlNode(serializer, node, XmlSerialization.XML_RETURNTYPE);
                XmlNodeList pNodes = node.SelectNodes(XmlSerialization.XML_PARAM);
                if (pNodes != null)
                {
                    _parameters = new ParameterDef[pNodes.Count];
                    for (int i = 0; i < pNodes.Count; i++)
                    {
                        _parameters[i] = (ParameterDef)XmlSerialization.ReadFromXmlNode(serializer, pNodes[i]);
                    }
                }
            }
            else
            {
                MethodType mt = new MethodType();
                mt.OnReadFromXmlNode(serializer, methodXmlNode);
                _retType = mt.ReturnType;
                Parameter[] ps = mt.Parameters;
                if (ps != null && ps.Length > 0)
                {
                    _parameters = new ParameterDef[ps.Length];
                    for (int i = 0; i < ps.Length; i++)
                    {
                        _parameters[i] = new ParameterDef(ps[i], ps[i].Name);
                    }
                }
            }
        }
Beispiel #10
0
        public void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
        {
            _owner = (ObjectRef)XmlSerialization.ReadFromChildXmlNode(serializer, node, XML_Owner);
            XmlNodeList nodes = node.SelectNodes(XmlSerialization.FormatString("{0}/{1}",
                                                                               XML_Inports, XmlSerialization.XML_PORT));

            _inports = new ProgramInPort[nodes.Count];
            for (int i = 0; i < nodes.Count; i++)
            {
                _inports[i] = (ProgramInPort)XmlSerialization.ReadFromXmlNode(serializer, nodes[i], this);
            }
            nodes = node.SelectNodes(XmlSerialization.FormatString("{0}/{1}",
                                                                   XML_Outports, XmlSerialization.XML_PORT));
            _outports = new ProgramOutPort[nodes.Count];
            for (int i = 0; i < nodes.Count; i++)
            {
                _outports[i] = (ProgramOutPort)XmlSerialization.ReadFromXmlNode(serializer, nodes[i], this);
            }
            _newInport  = (LinkLineNodeInPort)XmlSerialization.ReadFromChildXmlNode(serializer, node, XML_NewInport, this);
            _newOutport = (LinkLineNodeOutPort)XmlSerialization.ReadFromChildXmlNode(serializer, node, XML_NewOutport, this);
        }
Beispiel #11
0
 public void OnReadFromXmlNode(IXmlCodeReader serializer, XmlNode node)
 {
     _xpathNode = node;
     _name      = XmlSerialization.GetAttribute(node, XmlSerialization.XMLATT_NAME);
     _type      = (ObjectRefType)XmlSerialization.GetAttributeEnum(node, XMLATT_ObjRefType, typeof(ObjectRefType));
     if (_type == ObjectRefType.XPath)
     {
         if (!string.IsNullOrEmpty(_name))
         {
             _xpathNode = XmlSerialization.GetXmlNodeByPath(node.OwnerDocument, _name);
             if (_xpathNode == null)
             {
                 throw new MathException(string.Format("XPath with an invalid path value {0} for {1}", _name, node.OwnerDocument.DocumentElement.Name));
             }
         }
     }
     else
     {
         _owner = (ObjectRef)XmlSerialization.ReadFromChildXmlNode(serializer, node, "Owner", new object[] { null });
         _value = (Data)XmlSerialization.ReadFromChildXmlNode(serializer, node, "Value");
     }
 }
        /// <summary>
        /// implement IProgramEntity.ReturnCodeExpression
        /// if _castTo is null then this function returns the same as IMathExpression.ReturnCodeExpression
        /// </summary>
        /// <param name="portSelection"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public CodeExpression ReturnCodeExpression(object portSelection, IMethodCompile method)
        {
            CodeExpression ce = ReturnCodeExpression(method);

            if (_castTo != null)
            {
                IProgramPort p = portSelection as IProgramPort;
                if (p != null)
                {
                    ObjectRef prop = p.PortProperty;
                    if (prop != null)
                    {
                        StringCollection props = new StringCollection();
                        ce = new CodeCastExpression(_castTo.EntityType.TypeString, VPLUtil.GetCoreExpressionFromCast(ce));
                        while (true)
                        {
                            props.Add(prop.localName);
                            prop = prop.Owner;
                            if (prop == null)
                            {
                                break;
                            }
                            if (prop.IsSameType(_castTo.EntityType))
                            {
                                break;
                            }
                        }
                        for (int i = props.Count - 1; i >= 0; i--)
                        {
                            ce = new CodePropertyReferenceExpression(ce, props[i]);
                        }
                    }
                }
            }
            return(ce);
        }
Beispiel #13
0
 public ProgramEntity(ObjectRef owner)
 {
     _owner = owner;
 }