Example #1
0
        /// <summary>
        /// get BaseType of the object
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static Type GetObjectLibType(XmlNode node)
        {
            if (node == null)
            {
                return(typeof(object));
            }
            //string s = null;
            XmlNode baseNode = null;
            XmlNode nd;

            if (node.Name == XmlSerialization.RAIS_B)
            {
                nd = node;
            }
            else
            {
                nd = node.SelectSingleNode(XmlSerialization.RAIS_B);
            }
            while (nd != null)
            {
                baseNode = nd;
                nd       = nd.SelectSingleNode(XmlSerialization.RAIS_B);
            }
            if (baseNode != null)
            {
                Type t = XmlUtil.GetLibTypeAttribute(baseNode);
                if (t == null)
                {
                    throw new MathException(XmlSerialization.FormatString("Library type {0} cannot be resolved", XmlUtil.GetLibTypeAttributeString(baseNode)));
                }
                return(t);
            }
            return(typeof(void));
        }
Example #2
0
        public static bool HasConstructorActions(XmlNode typeNode, ConstructorInfo cif)
        {
            ParameterInfo[] ps   = cif.GetParameters();
            XmlNodeList     list = typeNode.SelectNodes(XmlSerialization.FormatString("{0}[@{1}='True']",
                                                                                      XmlSerialization.XML_METHOD, XmlSerialization.XMLATT_CONSTRUCTOR));

            foreach (XmlNode node in list)
            {
                MethodType mt = new MethodType();
                mt.OnReadFromXmlNode(null, node);
                if (mt.ParameterCount == ps.Length)
                {
                    bool bFound = true;
                    for (int i = 0; i < ps.Length; i++)
                    {
                        if (!mt.Parameters[i].DataType.Type.Equals(ps[i].ParameterType))
                        {
                            bFound = false;
                            break;
                        }
                    }
                    if (bFound)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #3
0
 /// <summary>
 /// find linked node and use that node's code.
 /// if not found then use default value
 /// </summary>
 /// <returns></returns>
 public override System.CodeDom.CodeExpression ExportCode(IMethodCompile method)
 {
     MathNode.Trace("{0}.ExportCode", this.GetType().Name);
     if (this.InPort != null)
     {
         if (this.InPort.LinkedPortID != 0)
         {
             MathExpItem mathParent = root.ContainerMathItem;
             if (mathParent == null)
             {
                 throw new MathException(XmlSerialization.FormatString("ExportCode for Default value: Linked port ID {0}. MathNodeRoot missing container.", this.InPort.LinkedPortID));
             }
             if (mathParent.Parent == null)
             {
                 throw new MathException(XmlSerialization.FormatString("ExportCode for Default value: Linked port ID {0}. MathExpItem missing container.", this.InPort.LinkedPortID));
             }
             MathExpItem item = mathParent.Parent.GetItemByID(this.InPort.LinkedPortID);
             if (item == null)
             {
                 throw new MathException(XmlSerialization.FormatString("ExportCode for Default value: Linked port ID {0} does not point to a valid port", this.InPort.LinkedPortID));
             }
             return(item.ReturnCodeExpression(method));
         }
     }
     return(ValueTypeUtil.GetDefaultValueByType(this.DataType.Type));
 }
Example #4
0
        public override CodeExpression ExportCode(IMethodCompile method)        //)
        {
            CodeStatementCollection supprtStatements = method.MethodCode.Statements;

            if (this.UseDefaultValue)
            {
                if (_default == null)
                {
                    MathNode.Trace("MathNodeParameter.ExportCode: Use default case 0:null");
                    return(ValueTypeUtil.GetDefaultCodeByType(this.DataType.Type));
                }
                else
                {
                    MathNode.Trace("MathNodeParameter.ExportCode: Use default case 1:{0}", _default);
                    return(ObjectCreationCodeGen.ObjectCreationCode(_default));
                }
            }
            else
            {
                if (this.InPort != null && this.InPort.LinkedPortID != 0)
                {
                    MathNode.Trace("MathNodeParameter.ExportCode: call linked item");
                    IMathExpression rootContainer = this.root.RootContainer;
                    if (rootContainer == null)
                    {
                        throw new MathException(XmlSerialization.FormatString("Parameter {0} not associated with a root container", this.TraceInfo));
                    }
                    MathExpItem LinkedItem = rootContainer.GetItemByID(this.InPort.LinkedPortID);
                    if (LinkedItem == null)
                    {
                        throw new MathException(string.Format("Linked Port ID {0} from ({1}) does not match an item", InPort.LinkedPortID, this.TraceInfo));
                    }
                    CodeExpression ce = LinkedItem.ReturnCodeExpression(method);
                    return(RaisDataType.GetConversionCode(LinkedItem.MathExpression.DataType, ce, this.DataType, supprtStatements));
                }
                //
                MathNode.Trace("MathNodeParameter.ExportCode: call MathNodeVariable.ExportCode");
                return(base.ExportCode(method));
            }
        }
Example #5
0
 public override string ToString()
 {
     return(XmlSerialization.FormatString("{0}++", this[0].ToString()));
 }
Example #6
0
 public MathException(Exception e, string message, params object[] values)
     : base(XmlSerialization.FormatString(message, values), e)
 {
 }
Example #7
0
 public override string ToString()
 {
     return(XmlSerialization.FormatString("random({0},{1})", this[0].ToString(), this[1].ToString()));
 }
 public override string ToString()
 {
     return(XmlSerialization.FormatString("Sum({0} - {1}:{2}", this[2].ToString(), this[3].ToString(), this[0].ToString()));
 }