public MessageInfo Describe () { if (desc != null) return desc; desc = new MessageInfo (); desc.message = name; desc.min_argc = 0; desc.max_argc = args.Length; foreach (ArgumentInfo info in args) { if (info.val == null && !info.collect) desc.min_argc++; if (info.collect) desc.max_argc = -1; } desc.default_argc = desc.min_argc; return desc; }
private MessageInfo[] ListMessages (string opt_filter) { ICollection method_list; if (obj == null) { ArrayList list = new ArrayList (obj_type.GetMethods ()); list.InsertRange (list.Count, typeof (Type).GetMethods ()); method_list = list; } else { method_list = obj_type.GetMethods (); } ArrayList info_list = new ArrayList (); Hashtable methods = new Hashtable (); if (opt_filter != String.Empty) { opt_filter = opt_filter.ToLower (); } foreach (MethodInfo method in method_list) { string method_lower = method.Name.ToLower (); if (opt_filter != String.Empty && method.Name.ToLower () != opt_filter) continue; MessageInfo info = (MessageInfo) methods[method_lower]; if (info == null) { info = new TypedMessageInfo (); info.message = method.Name; info.min_argc = -1; info.default_argc = -1; info.max_argc = 0; methods[method_lower] = info; info_list.Add (info); } ParameterInfo[] parms = method.GetParameters (); int count = (parms != null) ? parms.Length : 0; if (count > 0) { object[] attrs = parms[count - 1].GetCustomAttributes (typeof (System.ParamArrayAttribute), true); if (attrs != null && attrs.Length > 0) info.max_argc = -1; } object[] method_attrs = method.GetCustomAttributes (typeof (PassContextAttribute), true); if (method_attrs != null && method_attrs.Length > 0) { count--; } if (info.min_argc == -1 || count <= info.min_argc) { info.min_argc = count; info.default_argc = count; } method_attrs = method.GetCustomAttributes (typeof (DefaultArgumentCountAttribute), true); if (method_attrs != null && method_attrs.Length > 0) { info.default_argc = ((DefaultArgumentCountAttribute) method_attrs[0]).DefaultCount; } if (info.max_argc != -1 && count > info.max_argc) { info.max_argc = count; } } MessageInfo[] ret = new MessageInfo[info_list.Count]; info_list.CopyTo (ret, 0); return ret; }
private MessageInfo[] ListMessages(string opt_filter) { ICollection method_list; if (obj == null) { ArrayList list = new ArrayList(obj_type.GetMethods()); list.InsertRange(list.Count, typeof(Type).GetMethods()); method_list = list; } else { method_list = obj_type.GetMethods(); } ArrayList info_list = new ArrayList(); Hashtable methods = new Hashtable(); if (opt_filter != String.Empty) { opt_filter = opt_filter.ToLower(); } foreach (MethodInfo method in method_list) { string method_lower = method.Name.ToLower(); if (opt_filter != String.Empty && method.Name.ToLower() != opt_filter) { continue; } MessageInfo info = (MessageInfo)methods[method_lower]; if (info == null) { info = new TypedMessageInfo(); info.message = method.Name; info.min_argc = -1; info.default_argc = -1; info.max_argc = 0; methods[method_lower] = info; info_list.Add(info); } ParameterInfo[] parms = method.GetParameters(); int count = (parms != null) ? parms.Length : 0; if (count > 0) { object[] attrs = parms[count - 1].GetCustomAttributes(typeof(System.ParamArrayAttribute), true); if (attrs != null && attrs.Length > 0) { info.max_argc = -1; } } object[] method_attrs = method.GetCustomAttributes(typeof(PassContextAttribute), true); if (method_attrs != null && method_attrs.Length > 0) { count--; } if (info.min_argc == -1 || count <= info.min_argc) { info.min_argc = count; info.default_argc = count; } method_attrs = method.GetCustomAttributes(typeof(DefaultArgumentCountAttribute), true); if (method_attrs != null && method_attrs.Length > 0) { info.default_argc = ((DefaultArgumentCountAttribute)method_attrs[0]).DefaultCount; } if (info.max_argc != -1 && count > info.max_argc) { info.max_argc = count; } } MessageInfo[] ret = new MessageInfo[info_list.Count]; info_list.CopyTo(ret, 0); return(ret); }