Пример #1
0
 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));
 }
Пример #2
0
        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));
        }
Пример #3
0
 protected HookMetaData(HookAttribute hookAttrib)
 {
     HookAttrib = hookAttrib;
 }
Пример #4
0
 public MethodHookMetaData(MethodInfo method, HookAttribute hookAttrib)
     : base(hookAttrib)
 {
     this.method = method;
     instance    = Activator.CreateInstance(method.DeclaringType);
 }
Пример #5
0
 public DelegateHookMetaData(Action action, HookAttribute hookAttrib)
     : base(hookAttrib)
 {
     this.action = action;
 }