Nowadays, I’m working with WPF using MVVM pattern. To manage NHibernate session in viewmodels, I’m using the approach shown by Ayende, where session is a property of viewmodel. The problem is simple – sessions need to be disposed of and replaced after they throw an exception. That means we cannot use constructors to inject sessions … More Autofac OnActivated for all registrations
With Dependency Injection you typically inject an instance through constructor or property. That means that the whole dependency tree is resolved at once. In some cases, however, it is not acceptable and you need to control the creation of object instances from inside of a class. That’s when the need for object factories arises. Instead … More Implementing factories for Dependency Injection
I came across a piece of code similar to the following this week: The idea behind this is that the application was supposed to keep backwards compatibility with another system that used XML files to pass data back and forth and also support a newer version of that system, that uses special database tables to … More Getting rid of procedural code
A plugin, for those, who don’t know, is a component, that allows to extend an application without modifying it’s source code. The application loads plugins at runtime. In .NET it’s pretty easy to accomplish using Reflection capabilities. The easy way is to expose interfaces in your application assemblies, that the plugin can implement and use, … More A more extensible way to build plugin system
Since I learned about dependency injection, I always try to get rid of any Singleton pattern implementation I have in my projects. I admit, I had something other developers call ‘singletonitis’ – I used Singletons excessively. The reason that I liked Singletons so much was that when I switched my main programming language from C++ … More The hunt for Singletons
I’m developing a little project to learn a few tools including ASP.NET MVC 2, NHibernate and Unity. The project is a simple web page to upload and search through documents of many different formats. One of the requirements I’ve made out for the system is having three different roles for users: “Uploader”, “Manager” and “Administrator”.