private HookMetaData BuildMethodHookType(HookAttribute hookAttrib, MethodInfo method) { if (method.GetParameters().Any()) { var message = string.Format("Method {0} on class {1} may not have any parameters.", method.Name, method.DeclaringType.Name); throw new ArgumentException(message, "method"); } return(new MethodHookMetaData(method, hookAttrib)); }
private HookMetaData BuildDelegateHookType(HookAttribute hookAttrib, FieldInfo @delegate) { if (@delegate.FieldType != typeof(Action)) { var message = string.Format("Field {0} with attribute {1} must be of type SystemAction.", @delegate.Name, hookAttrib.GetType().Name); throw new ArgumentException(message, "delegate"); } var obj = GetInstance(@delegate); var action = (Action)@delegate.GetValue(obj); return(new DelegateHookMetaData(action, hookAttrib)); }
protected HookMetaData(HookAttribute hookAttrib) { HookAttrib = hookAttrib; }
public MethodHookMetaData(MethodInfo method, HookAttribute hookAttrib) : base(hookAttrib) { this.method = method; instance = Activator.CreateInstance(method.DeclaringType); }
public DelegateHookMetaData(Action action, HookAttribute hookAttrib) : base(hookAttrib) { this.action = action; }