Hey everyone,
I'm writing some unit tests in my project and I have a datacontext dependancy on the controller containing the methods I'd like to test.
I'm using Ninject to inject the dependancy and Moq to create my mock datacontext. My DI makes use of an interface IDataContext which my dbml impliments and is used through out the inject...
This is the interfaces/class structure I have now:
BaseContentObject abstract class
public abstract class BaseContentObject : IEquatable<BaseContentObject>
{
...
}
Page concrete class
public class Page : BaseContentObject
{
...
}
Repository interface
public interface IContentRepository<T>
{
// common methods for all c...
I have been using Ninject as the IOC for an XNA project, and was wanting to migrate it to Ninject 2.0. However, XNA is not dependency injection friendly, as certain classes must be instantiated in the constructor of the game class, but must pass the game class to their constructors as well. For example:
public MyGame ()
{
this.graph...
Hi,
I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf which is about the singleton actually creating more than a single instance if you're accessing it using different service types.
I'm using the latest release of Ninject 2 for Compact Framework and the exact issue I'm havin...
from what dll can i get the extension of Intercept ?
I've added Ninject.Extensions.Interception from http://github.com/danielmarbach/ninject.extensions.interception
No luck there.
Is there some sample working ?
What I need is to make an interceptor that will path through from WcfClient to WcfServer a different functions with different...
I have the following code in my Global.aspx
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
RegisterAllControllersIn(Assembly.GetExecutingAssembly());
}
protected override IKernel CreateKernel()
{
return new StandardKernel(new ServiceModule());
}
...
I am new to ninject using ninject 2.0. My application is hosted in asp.net mvc.
Now i don't know how to access kernel created in my class library.
I think i should create kernel in global.aspx and load all modules in it. But how can i make it available throughout application?
protected void Application_Start()
{
Regist...
Is there a way to use Property Injection in Ninject 2 without using the [Inject] attribute? This creates a dependency to Ninject in the class that will be wired using it and I prefer to avoid having unneeded dependencies to my IoC container, that's why I end up using Constructor Injection more often.
I guess the same applies to Method I...
I have been searching for a while.
I'm not new to dependency injection and have used StructureMap with several projects MVC and the like, but I felt like giving Ninject a go, so as not to miss out on the fun.
I am trying to use Ninject with an existing web app which I am bringing up-to-date.
I couldn't find on the blogs and wiki provi...
Hi Everyone.
I'm dev'ing an MVC 2 website targeting .NET 4.0 and using Ninject 2.0 (dev box running Win 7 64 pro). All is going well on the dev side, I really enjoyed using Ninject and it works a charm.
Until I deploy it to the server. Once I deploy the app to the server (a virtual machine running Win Server 2008 R2 x64, IIS 7.5) the...
I have the following httphandler:
public class NewHandler : IHttpHandler
{
[Inject]
public IFile FileReader
{
get;
set;
}
public NewHandler()
{
}
public void ProcessRequest(System.Web.HttpContext context)
{
....
var something = SomeMethod(FileReader);
....
...
Hi everybody,
I have just started to work with Ninject 2.0 with ASP.NET MVC 2.
So, I have an interface IMongoRepository and class MongoRepository.
MongoRepository receives a parameter string collection.
Depending on the collection I want to use, I pass in a different value in parameter for MongoRepository.
I hope I am phrasing this co...
A little question regarding Ninject.
I use a WCF 'duplex channel' to communicate with a service. The channel is defined as an interface, lets call it IMyChannel for simplicity. To instantiate a channel we use DuplexChannelFactory<IMyChannel> object's CreateChannel() method.
So far I have manage to bind the factory class with this.
Bin...
I have a situation where I want to dependency inject my user object, but also place the current user in the IoC container. I want the following lines to work:
kernel.Get<User>(); // Should return a new User()
kernel.Get<User>("Current"); // Should return the current user
One might think bindings like this would work:
Bind<User>().To...
Changes in Ninject 2 say that Ninject support Common Service Locator, but how do I use it? I don't find any manual or sample.
...
Hi all,
In a short view of the IoC and DI .NET libraries I chose to use Ninject2.
According to DDD style in:
Infrastructure: I have Entity Framework 4.0 .edmx model and the Repository implementation
Domain Layer: I have POCO objects and Repository Interfaces (implemented in Infrastructure)
Application Services: I have WCF services tha...
I just upgraded an existing implementation of Ninject from 1.5 to 2.0. I'm now seeing an intermittent exception getting thrown when many requests are happening in a short period of time.
Here's the exception that is being thrown.
Type: System.ArgumentException
Message: An item with the same key has already been added.
Source: ...
I have a single Ninject 2 Kernel for my application which contains all bindings. One section of the application needs to have different settings on the Kernel than the rest of the application, but needs the same bindings (that portion is for NHibernate and needs InjectNonPublic = true and the InjectAttribute set). How can a make a Kern...
I'm having a hard time with Ninject V2's InRequestScope() for managing a UnitOfWork.
_kernel.Bind<UnitOfWork>().To<SqlUnitOfWork>().InRequestScope();
I expect whenever I request the UnitOfWork via the container that the same object is always returned throughout the request. However, in the debugger I have a breakpoint on the object's ...
I'm using the Ninject.Web.Mvc (the MVC 2 version) add-on with ASP.NET MVC 2. This is an excerpt of my Global.asax.cs:
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes;
// RegisterAllControllersIn() is not available in the MVC 2 version of Ninject
}
protec...