Hi
I have a static class which calls a static Logger class,
e.g
static class DoesStuffStatic
{
public static void DoStuff()
{
try
{
//something
}
catch(Exception e)
{
//do stuff;
Logger.Log(e);
}
}
}
static class Logger
{
public static void Log(Exception e)
{
//do stuff here
...
Hi,
I'm a newbie when it comes to DI and ninject and I'm struggling a bit
about when the actual injection should happen and how to start the
binding.
I'm using it already in my web application and it working fine there,
but now I want to use injection in a class library.
Say I have a class like this:
public class TestClass
{
...
XML seems to be the language of the day, but it's not type safe (without an external tool to detect problems) and you end up doing logic in XML. Why not just do it in the same language as the rest of the project. If it's java you could just build a config jar and put it on the classpath.
I must be missing something deep.
...
Hi,
It is very common to create Dependency Injection container for the ASP.NET application so it lives while the application lives.
I create the DI container in each request and release it at the end of the request.
The main purpose is that any DI container supports Disposing objects when the container gets disposed.
Additional: ...
A couple of days ago, I saw the CoClassAttribute being used in a way I haven't imagined before.
[ComImport, CoClass(typeof(Foo)), Guid("787C1303-AE31-47a2-8E89-07C7257B1C43")]
interface IFoo {
void Bar();
}
class Foo : IFoo {
public void Bar() {
Console.WriteLine("Oh retado!");
}
}
being used as:
class CoClass...
I have the following structure in my web solution:
Domain
DataAccess
ApplicationServices
Web
Tests
I have some application services that I am using to abstract some web services that I am using. (Specifically, I am bundling some shipping web services together into a single application service.) Should my Application Services laye...
I have been reading up on Dependency Injection frameworks. I really fell in love with the idea of separating the concerns and letting the objects do their core work - which is undoubtedly an excellent and long-standing design principle!
However the more I read on DI frameworks, the more I get worried:
1) In the way they "automagically" ...
I am writing a desktop GIS application and it supports MapXtreme, MS Virtual Earth and our Custom Map Engine.Users of application can change the map engine at run-time by selecting from dropdownlist.I have a Factory class to change map engine like this.
public class MapFactory implements IMapFactory
{
public IMapEngine createInstanc...
Hi
Does anyone know how to have dependency injection work with linq2sql. Heres my situation..
I will explain it as best i can here.
I have a base class which has a DBML (linq2sql) and classes etc .. This DBML is COMMON to more than 1 project.. Well each project has its own DBML but has all the tables etc that is in the common dbml i a...
We basically need to be able to adjust behaviour at start-up time, by providing desired classes to be produced by various factories inside our application (to avoid the hard binding of the "new" operator).
I am aware that this is provided by several large frameworks, but I was looking for something easily used by a stand-alone Java appl...
I just started working with dependency injection for the first time and I am using as Ninject 2.0 as my IoC container in an ASP.NET MVC 2 website and I'm hitting an activation error that I am not sure how to react to. I am sure it's simple so hopefully someone can point me in the right direction without too much thought.
I have a proper...
Consider:
public class HomeController : Controller {
private IDependency iDependency;
public HomeController(IDependency iDependency) {
this.iDependency = iDependency;
}
}
And the fact that Controllers in ASP.NET MVC must have one empty default constructor(*) is there any way other than defining an empty (and usel...
I'm using a basic 3-tier design. For flexibility (and testing) purposes, I wanted the data layer to be abstract and specify the concrete class in my code. But, how should I pass this along to my business objects. Here's an example (pseudo code):
abstract class IDataLayer
{
PersonData GetPerson(int); //PersonData would be a row of da...
I have two closely related applications that are both using the Unity IoC container. They have some custom types in common, but not all of them. At the moment I have two config files that have a lot of duplication. I'd like to have just one Unity config file to rule them all.
However, as not all types exist in both applications Unity i...
Using Spring I've had some issues with doing a dependency injection on an annotated Aspect class. CacheService is injected upon the Spring context's startup, but when the weaving takes place, it says that the cacheService is null. So I am forced to relook up the spring context manually and get the bean from there.
Is there another way ...
Is there an equivalent xml configuration for StructureMap's Registry DSL configuration:
ForRequestedType<T>().TheDefaultIsConcreteType<T>();
There is some limited documentation around Structure Map's XML Configuration on the SM site, but I have yet to get any XML configuration items to override Registry DSL entries. Is there a way ...
I've implemented a repository pattern with persistence ignorance. The repository implementation only interacts with my entity objects, IUnitOfWork and ITable<T> interfaces. The intention is that the IUnitOfWork isn't reused but represents a single transaction. So far, I've implemented in-memory as well as Linq-to-Sql versions of the IUni...
What are they of each other?
Specification and implementation?
Competitors?
Unrelated?
...
I'm trying to work with NInject but fail on this simple case: I have 2 implementations for for IMessage like this
public interface IMessage
{
string Message();
}
public class WelcomeMessage: IMessage
{
#region IMessage Members
public string Message()
{
return "Welcome user!";
}
#endregion
}
public cla...
I see lots of articles saying how great IoC and DI are and none about why it isn't so great because it can make code more complex. I see also that IoC shouldn't be in the core part of your code but more for libraries and plug-ins. Articles usually a small reference to how the two patterns can make code more complicated but not much on t...