public void Register(String commandName, Object type) { var aMethod = new ExtendedMethodInfo { MethodInfo = type.GetType().GetMethod(commandName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy), Context = type }; aMethod.Method = (ExtendedMethodInfo.MethodType) Delegate.CreateDelegate(typeof(ExtendedMethodInfo.MethodType), aMethod.Context, aMethod.MethodInfo); _commands.Add(commandName, aMethod); }
public void Register(String commandName, Type type) { var aMethod = new ExtendedMethodInfo { MethodInfo = type.GetMethod(commandName) }; aMethod.Method = (ExtendedMethodInfo.MethodType) Delegate.CreateDelegate(typeof(ExtendedMethodInfo.MethodType), aMethod.MethodInfo); _commands.Add(commandName, aMethod); }
public void Register(Type type) { MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); foreach (MethodInfo rawMethod in methods) { var aMethod = new ExtendedMethodInfo { MethodInfo = rawMethod }; aMethod.Method = (ExtendedMethodInfo.MethodType) Delegate.CreateDelegate(typeof(ExtendedMethodInfo.MethodType), aMethod.MethodInfo); _commands.Add(rawMethod.Name, aMethod); } }
public void Register(Object type) { MethodInfo[] methods = type.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy); foreach (MethodInfo rawMethod in methods) { if (rawMethod.ReturnType == typeof(Object)) { var aMethod = new ExtendedMethodInfo(); if (!rawMethod.IsStatic) { aMethod.Context = type; } aMethod.MethodInfo = rawMethod; aMethod.Method = (ExtendedMethodInfo.MethodType) Delegate.CreateDelegate(typeof(ExtendedMethodInfo.MethodType), aMethod.Context, aMethod.MethodInfo); _commands.Add(rawMethod.Name, aMethod); } } }
public ExtendedMethodInfo ExtendInfo(MethodInfo info) { var ni = new ExtendedMethodInfo() { Info = info }; if (!ReflectionHelpers.IsFullyFledgedMethod(info)) { ni.IsMapped = false; return(ni); } var attr = info.GetCustomAttribute <JsCallableAttribute>(); if (attr == null) { ni.IsMapped = false; return(ni); } ni.Name = attr.FunctionName; ni.IsMapped = true; return(ni); }