You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if this is a bug or not, but I have a class like so in a console app example:
public class SaySomethingAction : IAction
{
public virtual void Run()
{
Console.WriteLine("Type in what you want to say, then press enter");
var message = Console.ReadLine();
Say(message);
}
[DelayFor(2)]
public virtual void Say(string message)
{
Console.WriteLine($"Saying {message}");
}
}
So my expectations is that when the Run method invokes Say it would trigger the DelayFor attribute (which is an InterceptAttribute), which would in turn call through to the relevant interceptor. However the interceptor associated with that attribute is not fired on Say, however if I were to put the [DelayFor(2)] onto the Run method, that WOULD correctly trigger and proxy the method.
So is this use case supported?
The text was updated successfully, but these errors were encountered:
hmmm thinking about it Say is not part of the interface IAction only Run is... so maybe that is the problem, but that being said, is there a way to achieve this?
Would you be able to Inject another custom class that contains your Say function into SaySomethingAction by puting a constructor that accepts that class? For Example:
publicclassSaySomethingAction:IAction{privatereadonlyDelayedSayFunction_delayedSayFunction;publicSaySomethingAction(DelayedSayFunctiondelayedSayFunction){_delayedSayFunction=delayedSayFunction;}publicvirtualvoidRun(){Console.WriteLine("Type in what you want to say, then press enter");varmessage=Console.ReadLine();_delayedSayFunction.Say(message);}}publicclassDelayedSayFunction{[DelayFor(2)]publicvirtualvoidSay(stringmessage){Console.WriteLine($"Saying {message}");}}
Of course you would have to set up the Binding Bind().ToSelf();
Honestly never tried this on the IAction, but ninject seems to let you inject to any constructor that comes from the Kernel which the IActions should. Let me know if that ends up working I may have interest in this some day.
I am not sure if this is a bug or not, but I have a class like so in a console app example:
So my expectations is that when the
Run
method invokesSay
it would trigger theDelayFor
attribute (which is anInterceptAttribute
), which would in turn call through to the relevant interceptor. However the interceptor associated with that attribute is not fired onSay
, however if I were to put the[DelayFor(2)]
onto theRun
method, that WOULD correctly trigger and proxy the method.So is this use case supported?
The text was updated successfully, but these errors were encountered: