ninject-extensions

Add behaviorattribute to a WorkflowServiceHost

僤鯓⒐⒋嵵緔 提交于 2019-12-06 11:20:18
问题 Hi all i have a problem while adding a custom behavior to a WorkflowServiceHost. Here is my WorflowServiceHostFactory: public class ScoringWorkflowServiceHostFactory : WorkflowServiceHostFactory, IServiceHost<IKernel> { private static IKernel _InjectionInstance; public IKernel InjectionInstance { get { return _InjectionInstance ?? (_InjectionInstance = new StandardKernel(new ScoringWorkflowServicesNinjectModule(Scope))); } } public object Scope { get { return Guid.NewGuid(); } } public

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); } }

Get ninject factory extension to allow factory parameters be passed to dependencies

此生再无相见时 提交于 2019-12-06 04:36:33
问题 Using the Ninject Factory extension, you can automatically generate factories, and let the factory pass parameters to the class' constructor. The following test passes: public interface IBar { int Foo { get; } } public class Bar : IBar { int _foo; public Bar(int foo) { _foo = foo; } public int Foo { get { return _foo; } } } public interface IBarFactory { IBar CreateTest(int foo); } [Test] public void ExecuteTest() { var kernel = new StandardKernel(); kernel.Bind<IBar>().To<Bar>(); kernel.Bind

Add behaviorattribute to a WorkflowServiceHost

醉酒当歌 提交于 2019-12-04 15:15:53
Hi all i have a problem while adding a custom behavior to a WorkflowServiceHost. Here is my WorflowServiceHostFactory: public class ScoringWorkflowServiceHostFactory : WorkflowServiceHostFactory, IServiceHost<IKernel> { private static IKernel _InjectionInstance; public IKernel InjectionInstance { get { return _InjectionInstance ?? (_InjectionInstance = new StandardKernel(new ScoringWorkflowServicesNinjectModule(Scope))); } } public object Scope { get { return Guid.NewGuid(); } } public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses) { String

Setup Ninject for WCF [closed]

孤者浪人 提交于 2019-12-04 09:19:30
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Does anyone have a clear instruction on how to setup Ninject in WCF? been googling around but I cant see any updated guidelines on how to use Ninject in WCF. 回答1: Using NInject with WCF is the same as using any other DI container. To do this you need to use 3 WCF extensibility points: InstanceProvider ,

Interception with Ninject. Fails to load IProxyRequestFactory

大憨熊 提交于 2019-12-04 08:00:58
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); } } And have a class named MyClass which got nothing but 2 simple methods, virtual to allow the interceptors

NamedLikeFactoryMethod in Ninject Extensions Factory working in non-compliance with documentation

限于喜欢 提交于 2019-12-04 06:41:20
问题 I have a small issue with my simple example. I have simple factory interface: public interface ICameraFactory { ICameraController GetNikonCamera(); ICameraController GetCanonCamera(); } I bind it as a factory: IKernel kernel = new StandardKernel(); kernel.Bind<ICameraFactory>().ToFactory(); When i try to convert: kernel.Bind<ICameraController>().To<NikonCameraController>() .Named("NikonCamera"); to: kernel.Bind<ICameraController>().To<NikonCameraController>() .NamedLikeFactoryMethod

Does Ninject Conventions only work for public classes?

久未见 提交于 2019-12-04 05:22:36
问题 I started using Ninject for my project, to automatically bind all subclasses of an abstract class. The binding for this is -- nice and easy -- as follows: kernel.Bind(x => x.FromThisAssembly() .SelectAllClasses(). .InheritedFrom<AbstractGenerator>() .BindBase()); However, I found that this doesn't work. After some experimenting I found that the reason for this not working is that all my implementations (and the abstract class) are marked internal . I could imagine this to be some security

Ninject 3 InRequestScope not returning the same instance for the same request

折月煮酒 提交于 2019-12-04 02:59:18
问题 Recently, I upgraded one of my MVC3 projects from Ninject 2 to Ninject 3. After a couple of minutes trying to find why InRequestScope was not anymore available, I found that this is now an extension of Ninject.Web.Common. Now, when I try to run the application, Ninject works like if all types binded with a scope InRequest would be InTransientScope; a new instance was created each time. In my class that inherits from NinjectModule, I have a simple bind like that: Bind<ViewModel.Activity>()

Ninject.Extensions.Logging.Log4net unexpected behavior

别来无恙 提交于 2019-12-03 14:16:32
I am having a problem using Log4Net (1.2.10) through Ninject's (2.2.1.4) Extensions.Logging.Log4net (2.2.0.4), as installed through NuGet. When I access Log4Net directly: var logger = log4net.LogManager.GetLogger("Log4NetLoggerTest"); logger.Debug("foo { bar"); The result is: 2011-08-29 10:02:02,071 [9] DEBUG Log4NetLoggerTest foo { bar However, when the logger is accessed through Ninject: using (IKernel kernel = new StandardKernel()) { var ninjectLogger = kernel.Get<NinjectLoggerTest>(); ninjectLogger.Log.Debug("foo { bar"); } Where NinjectLoggerTest is simply this: using Ninject.Extensions