Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
Your profile
Tag cloud
.net .net 3.5 .net 4.0 2003 access modifiers beginners book buildup c# f# generate linq log4net microsoft reporting engine nhibernate nhprof nunit programming rdlc reflection reportviewer resharper rhino mocks structuremap template unit testing vb.net visual studio 2010 windows forms wpf
Authors
- chrissie1 (119)

- SQLDenis (17)

- Alex Ullrich (8)

- chaospandion (2)

- George Mastros (1)

- chopstik (1)

- tarwn (1)

- remou (1)

- More...
Main Categories
Search
Google Ads
Tags: structuremap
For my usercontrols I tend to use the StructureMap BuildUp feature. I will leave it to the big man himself to introduce you to this feature.
I use property injection in this case because the designer doesn't like usercontrols that have constructors that are not empty, since it will try to execute the code in that constructor. So we revert to property injection and the BuildUp feature....
So we have a windows forms application and some of these forms can only be used once. Like for instance a dashboard. Everytime we show the form we just want it to either show a new one, if it's the first time opened, or we want to show the one that already exists. In essence, this would be good case for a singleton pattern. But the singleton pattern is evil. Why is it evil? Because it is hard to unittest. And it makes us do something that we really don't want to.
So having established that we got to find a better solution for this poblem. And we have. It's called StructureMap. Stru...
So you have lots of forms in your winforms application and you have to open them from several places/forms. But you don't want to repeat yourself all the time. And you like to keep things centralized. You also want it to be flexible, if possible and easily extendable/extensible/extendingable, uhm, be able to extend it in an easy manner. I think this is a typical case for the command pattern. So let's start with that.
Warning! what follows is a lot of code. So this will be a long post. But you can skip all the parts you don't like. Not that you will.
Let's start by creating a...
In my previous post I already mentioned the BuildUp method in StructureMap and how cool that can be. And now I want to show you how to do this in VB.Net. As we all know VB.Net doesn't like Multiline lambdas or void lambdas. But we will kill somebody for that later. In this example I also used a real form and it didn't get hurt by the designer this time.
The code is pretty much the same as my previous post.
Here are the services and their interfaces.
And it just got cooler. After I read this "BuildUp" Existing Objects with StructureMap I got an aha moment. The BuildUp function that was recently added just solved my very ugle winforms usercontrol problem. I use to have to add objectfactory.getinstance code in the constructors to get my dependencies just to keep the designer happy. I hate to design winforms without the designer but the designer hates me. But now this love hate relationship has bcome a little...
:: Next >>


LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.