static bool IsVisibleXmlRpcMethod(MethodInfo mi) { bool ret = false; Attribute attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); if (attr != null) { XmlRpcMethodAttribute mattr = (XmlRpcMethodAttribute)attr; ret = !(mattr.Hidden || mattr.IntrospectionMethod == true); } return(ret); }
bool IsVisibleXmlRpcMethod(MethodInfo mi) { bool ret = false; Attribute attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); if (attr != null) { XmlRpcMethodAttribute mattr = (XmlRpcMethodAttribute)attr; ret = !mattr.Hidden; } return(ret); }
public static string GetXmlRpcMethodName(MethodInfo mi) { XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute) Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); if (attr != null && attr.Method != null && attr.Method != "") { return(attr.Method); } else { return(mi.Name); } }
private static string GetXmlRpcMethodName(MethodInfo mi) { Attribute attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); if (attr == null) { return(null); } XmlRpcMethodAttribute xrmAttr = attr as XmlRpcMethodAttribute; string rpcMethod = xrmAttr.Method; if (rpcMethod == "") { rpcMethod = mi.Name; } return(rpcMethod); }
static void BuildMethods(TypeBuilder tb, ArrayList methods) { foreach (MethodData mthdData in methods) { MethodInfo mi = mthdData.mi; Type[] argTypes = new Type[mi.GetParameters().Length]; string[] paramNames = new string[mi.GetParameters().Length]; for (int i = 0; i < mi.GetParameters().Length; i++) { argTypes[i] = mi.GetParameters()[i].ParameterType; paramNames[i] = mi.GetParameters()[i].Name; } XmlRpcMethodAttribute mattr = (XmlRpcMethodAttribute) Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); BuildMethod(tb, mi.Name, mthdData.xmlRpcName, paramNames, argTypes, mthdData.paramsMethod, mi.ReturnType, mattr.StructParams); } }
string GetRpcMethodName(MethodInfo mi) { Attribute attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); // TODO: do methods need attribute? // if (attr == null) // { // throw new Exception("missing method attribute"); // } string rpcMethod = ""; if (attr != null) { XmlRpcMethodAttribute xrmAttr = attr as XmlRpcMethodAttribute; rpcMethod = xrmAttr.Method; } if (rpcMethod == "") { rpcMethod = mi.Name; } return(rpcMethod); }
string GetRpcMethodName(object clientObj, MethodInfo mi) { string rpcMethod; string MethodName = mi.Name; Attribute attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcBeginAttribute)); if (attr != null) { rpcMethod = ((XmlRpcBeginAttribute)attr).Method; if (rpcMethod == "") { if (!MethodName.StartsWith("Begin") || MethodName.Length <= 5) { throw new Exception(String.Format( "method {0} has invalid signature for begin method", MethodName)); } rpcMethod = MethodName.Substring(5); } return(rpcMethod); } // if no XmlRpcBegin attribute, must have XmlRpcMethod attribute attr = Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); if (attr == null) { throw new Exception("missing method attribute"); } XmlRpcMethodAttribute xrmAttr = attr as XmlRpcMethodAttribute; rpcMethod = xrmAttr.Method; if (rpcMethod == "") { rpcMethod = mi.Name; } return(rpcMethod); }
static void ExtractMethodInfo(Hashtable methods, MethodInfo mi, Type type) { XmlRpcMethodAttribute attr = (XmlRpcMethodAttribute) Attribute.GetCustomAttribute(mi, typeof(XmlRpcMethodAttribute)); if (attr == null) { return; } XmlRpcMethodInfo mthdInfo = new XmlRpcMethodInfo(); mthdInfo.MethodInfo = mi; mthdInfo.XmlRpcName = GetXmlRpcMethodName(mi); mthdInfo.MiName = mi.Name; mthdInfo.Doc = attr.Description; mthdInfo.IsHidden = attr.IntrospectionMethod | attr.Hidden; // extract parameters information ArrayList parmList = new ArrayList(); ParameterInfo[] parms = mi.GetParameters(); foreach (ParameterInfo parm in parms) { XmlRpcParameterInfo parmInfo = new XmlRpcParameterInfo(); parmInfo.Name = parm.Name; parmInfo.Type = parm.ParameterType; parmInfo.XmlRpcType = GetXmlRpcTypeString(parm.ParameterType); // retrieve optional attributed info parmInfo.Doc = ""; XmlRpcParameterAttribute pattr = (XmlRpcParameterAttribute) Attribute.GetCustomAttribute(parm, typeof(XmlRpcParameterAttribute)); if (pattr != null) { parmInfo.Doc = pattr.Description; parmInfo.XmlRpcName = pattr.Name; } parmInfo.IsParams = Attribute.IsDefined(parm, typeof(ParamArrayAttribute)); parmList.Add(parmInfo); } mthdInfo.Parameters = (XmlRpcParameterInfo[]) parmList.ToArray(typeof(XmlRpcParameterInfo)); // extract return type information mthdInfo.ReturnType = mi.ReturnType; mthdInfo.ReturnXmlRpcType = GetXmlRpcTypeString(mi.ReturnType); object[] orattrs = mi.ReturnTypeCustomAttributes.GetCustomAttributes( typeof(XmlRpcReturnValueAttribute), false); if (orattrs.Length > 0) { mthdInfo.ReturnDoc = ((XmlRpcReturnValueAttribute)orattrs[0]).Description; } if (methods[mthdInfo.XmlRpcName] != null) { throw new XmlRpcDupXmlRpcMethodNames(String.Format("Method " + "{0} in type {1} has duplicate XmlRpc method name {2}", mi.Name, type.Name, mthdInfo.XmlRpcName)); } else { methods.Add(mthdInfo.XmlRpcName, mthdInfo); } }