public XmlDocument GetXmlDocument() { if (_devType != null) { return(_devType.GetXmlDocument()); } return(null); }
/// <summary> /// retrieve _retyrnType and parameters /// </summary> private void getSignature() { if (string.IsNullOrEmpty(_methodName)) { throw new MathException("Accessing getSignature with empty method name"); } if (_methodOwnerObjectRef == null) { throw new MathException("Accessing getSignature with null owner"); } if (_methodOwnerObjectRef.Type == ObjectRefType.Type) { Type t = _methodOwnerObjectRef.Value.LibType; MethodInfo mi = t.GetMethod(_methodName); if (mi == null) { throw new MathException("Accessing getSignature with invalid method name '{0}'", _methodName); } getSignature(mi); } else if (_methodOwnerObjectRef.Type == ObjectRefType.Field || _methodOwnerObjectRef.Type == ObjectRefType.Property) { if (_methodOwnerObjectRef.Owner.Type == ObjectRefType.XPath) { } else if (_methodOwnerObjectRef.Owner.Type == ObjectRefType.Type) { MethodInfo mi = null; Type t = _methodOwnerObjectRef.Owner.Value.LibType; if (_methodOwnerObjectRef.Type == ObjectRefType.Field) { FieldInfo fi = t.GetField(_methodOwnerObjectRef.Name); if (fi == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature for Field with invalid field name {0} for type {1}", _methodOwnerObjectRef.Name, t)); } mi = fi.FieldType.GetMethod(_methodName); if (mi == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature for Field with invalid method name {0} for field name {1} and type {2}", _methodName, _methodOwnerObjectRef.Name, t)); } } else if (_methodOwnerObjectRef.Type == ObjectRefType.Property) { PropertyInfo pi = t.GetProperty(_methodOwnerObjectRef.Name); if (pi == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature for Property with invalid property name {0} for type {1}", _methodOwnerObjectRef.Name, t)); } mi = pi.PropertyType.GetMethod(_methodName); if (mi == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature for Property with invalid method name {0} for Property name {1} and type {2}", _methodName, _methodOwnerObjectRef.Name, t)); } } getSignature(mi); } throw new MathException(XmlSerialization.FormatString("Accessing getSignature for Field. Owner type {0} not implemented", _methodOwnerObjectRef.Owner.Type)); } else if (_methodOwnerObjectRef.Type == ObjectRefType.XPath) { XmlDocument doc = _methodOwnerObjectRef.GetXmlDocument(); if (doc == null) { throw new MathException("Accessing getSignature with null document"); } XmlNode prj = XmlSerialization.GetProjectNode(doc); if (prj == null) { throw new MathException("Accessing getSignature with null project"); } XmlNode ownNode = prj.SelectSingleNode(_methodOwnerObjectRef.XPath); if (ownNode == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature with invalid xpath {0}", _methodOwnerObjectRef.XPath)); } if (_methodName == XmlSerialization.CONSTRUCTOR_METHOD) { throw new MathException("Accessing getSignature when the method is a constructor"); } XmlNode methodNode = ownNode.SelectSingleNode(XmlSerialization.FormatString("{0}[@{1}='{2}']", XmlSerialization.XML_METHOD, XmlSerialization.XMLATT_NAME, _methodName)); if (methodNode == null) { Type t = XmlSerialization.GetObjectLibType(ownNode); if (t == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature with valid xpath {0} but method name {1} not found and owner library type not found", _methodOwnerObjectRef.XPath, _methodName)); } MethodInfo mif = t.GetMethod(_methodName); if (mif == null) { throw new MathException(XmlSerialization.FormatString("Accessing getSignature with valid xpath {0} but method name {1} not found in owner library type {2}", _methodOwnerObjectRef.XPath, _methodName, t.Name)); } getSignature(mif); } else { MethodType mt = new MethodType(); mt.OnReadFromXmlNode(null, methodNode); _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]); } } } } throw new MathException(XmlSerialization.FormatString("Accessing getSignature: type not implemented: {0}", _methodOwnerObjectRef.Type)); }