Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Robotlegs/Bender/Framework/Impl/Guards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public static bool Approve(IInjector injector, IEnumerable<object> guards)
MethodInfo approveMethod = guardInstance.GetType().GetMethod("Approve");
if (approveMethod != null)
{
//Before we invoke Approve, inject any needed values
if (injector != null && guardInstance.GetType().IsClass)
injector.InjectInto(guardInstance);

if ((bool)approveMethod.Invoke (guardInstance, null) == false)
return false;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Robotlegs/Bender/Framework/Impl/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ public static void Apply(IInjector injector, IEnumerable<object> hooks)

MethodInfo hookMethod = hookInstance.GetType().GetMethod("Hook");
if (hookMethod != null)
{
//Before we invoke Hook, inject any needed values
if (injector != null && hookInstance.GetType().IsClass)
injector.InjectInto(hookInstance);

hookMethod.Invoke (hookInstance, null);
}
else
throw new Exception ("Invalid hook to apply");
}
Expand Down