ninject-interception

Can't get Ninject.Extensions.Interception working

淺唱寂寞╮ 提交于 2020-08-02 05:53:48
问题 I've been trying for ages to figure this our. when i try to bind my class with an interceptor i'm getting the following exception on the line Kernel.Bind<MyClass>().ToSelf().Intercept().With<ILoggerAspect>(); Error loading Ninject component IAdviceFactory. No such component has been registered in the kernel's component container I've tried with and without LoadExtensions, With about with using a Module to set up my bindings and my last attempt looks like this internal class AppConfiguration {

How to inject an action into a command using Ninject?

孤人 提交于 2020-01-06 19:34:11
问题 Actually exploring the Command Pattern and finds it pretty interesting. I'm writing a WPF Windows App following the MVVM Architectural Pattern. I've begun with these post which explain the basics. Basic MVVM and ICommand usuage example Simplify Distributed System Design Using the Command Pattern, MSMQ, and .NET Now that I was able to break user actions into commands, I thought this could be great to inject the commands that I want. I noticed that the commands are found into the ViewModel in

How to inject an action into a command using Ninject?

空扰寡人 提交于 2020-01-06 19:34:01
问题 Actually exploring the Command Pattern and finds it pretty interesting. I'm writing a WPF Windows App following the MVVM Architectural Pattern. I've begun with these post which explain the basics. Basic MVVM and ICommand usuage example Simplify Distributed System Design Using the Command Pattern, MSMQ, and .NET Now that I was able to break user actions into commands, I thought this could be great to inject the commands that I want. I noticed that the commands are found into the ViewModel in

Ninject Interception 3.0 Interface proxy by method attributes

a 夏天 提交于 2019-12-25 06:26:29
问题 I have just upgraded a relatively large codebase from Ninject 2.2 to Ninject 3.0. Everything seems to be going as planned except I had to make a few changes to the interception stuff that we use. interface IFoo { Bar GetBar(); } class Foo : IFoo { [LogMethod(Level = LogLevel.Error)] public virtual Bar GetBar() { return new Bar(); } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] class LogMethodAttribute

Ninject interception proxying class with non empty constructor via castle dynamic proxy

人走茶凉 提交于 2019-12-22 11:00:12
问题 I am basing most of my current implementation off the information provided here: Ninject Intercept any method with certain attribute? I use a custom planning strategy class which looks for all methods with given attributes (not ninject interceptor attributes) which will then get proxied if it matches the criteria. An example of usage would be: Kernel.Components.Add<IPlanningStrategy, CustomPlanningStrategy<LoggingAttribute, LoggerInterceptor>>(); This would then look for any methods which

Making Ninject Interceptors work with async methods

佐手、 提交于 2019-12-21 17:09:50
问题 I am starting to work with ninject interceptors to wrap some of my async code with various behaviors and am having some trouble getting everything working. Here is an interceptor I am working with: public class MyInterceptor : IInterceptor { public async void Intercept(IInvocation invocation) { try { invocation.Proceed(); //check that method indeed returns Task await (Task) invocation.ReturnValue; RecordSuccess(); } catch (Exception) { RecordError(); invocation.ReturnValue = _defaultValue;

Intercept creation of instances in Ninject

▼魔方 西西 提交于 2019-12-11 10:16:20
问题 I am looking to intercept the creation of instances that implement a certain interface, or have a certain attribute. I am able to do something similiar with the interception extension, but that only seems to do method and property interception. Here is how I can intercept method and property calls, but it doesn't intercept the constructor call: _kernel.Bind<IInterceptor>().To<LogInterceptor>().InSingletonScope(); _kernel.Intercept(x => { if (x.Plan.Type.GetInterface(typeof

How to set up an optional method interception with Ninject?

萝らか妹 提交于 2019-12-07 06:11:01
问题 Suppose I have a class in which I want to sometimes* (but now always) intercept some (but not all) methods. The way I understand it, this can be done either with, say, InterceptAround() in my Ninject module (in the higher-level code), or with an InterceptAttribute-derived attribute on those methods (at the implementation level). I don't really like the first way of doing it, because it requires the consumer to know the details, there'll be many classes with many methods. But I don't like the

Interception with Ninject. Fails to load IProxyRequestFactory

本小妞迷上赌 提交于 2019-12-06 04:38:56
问题 I'm learning to use Ninject and Interceptor pattern. I have the following interceptor. public class MyInterceptor:IInterceptor { public void Intercept(IInvocation invocation) { Console.WriteLine("Pre Execute: " + invocation.Request.Method.Name); foreach (var param in invocation.Request.Arguments) { Console.WriteLine("param : " + param); } invocation.Proceed(); Console.WriteLine("Post Execute: " + invocation.Request.Method.Name); Console.WriteLine("Returned: " + invocation.ReturnValue); } }

How to set up an optional method interception with Ninject?

安稳与你 提交于 2019-12-05 12:25:58
Suppose I have a class in which I want to sometimes* (but now always) intercept some (but not all) methods. The way I understand it, this can be done either with, say, InterceptAround() in my Ninject module (in the higher-level code), or with an InterceptAttribute-derived attribute on those methods (at the implementation level). I don't really like the first way of doing it, because it requires the consumer to know the details, there'll be many classes with many methods. But I don't like the second way either, since I don't see how to disable (or, rather, not to enable) the interception, as