ServiceLocator and Unity – Be Careful

Chris Tavarez has provided a handy adapter (UnityServiceLocator) for using ServiceLocator to resolve types from a Unity container.  You can then use ServiceLocator.SetLocatorProvider() to register the UnityServiceLocator as the default provider for ServiceLocator.  For this example, we will be using ServiceLocator and Unity to resolve the type IFoo to Foo using a singleton lifetime.  Then…

3

Tip: Entity Framework, Unity, and The ASP.NET RoleProvider – Read the MSDN Fine Print

A custom Role Provider is a very useful tool for adding custom authorization to your ASP.NET and/or ASP.NET MVC applications.  A common use for a custom Role Provider is when you have role information stored in a data store that differs from the schema that is used by the built-in ASP.NET Role Providers.  In this…

2

Testing Your Unity XML Configuration

When using Unity as your IoC container, one way to configure the container is to use an configuration section in your app.config or web.config file.  A simplified example of this configuration is shown below: 1: <?xml version=”1.0″ encoding=”utf-8″ ?> 2: <configuration> 3: <configSections> 4: <section name=”unity” type=”Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration” /> 5: </configSections> 6:  7: <unity> 8:…

2

Unit Testing The MVC JsonResult

One of my favorite features of ASP.NET MVC is the support for JSON.  In MVC, an Action Method in a Controller can return a JsonResult.  This really comes in handy when integrating with jQuery to provide AJAX-like functionality in an application. In this post, I am going to share some of the different ways that…

11

The Plethora Of Prodigal Patterns

“Make everything as simple as possible, but not simpler” Albert Einstein With all of the software design patterns available to developers, I think that we sometimes lose focus of the pragmatic development approach: Write code that works. Don’t get me wrong, I do believe that software patterns are a very valuable tool in the software…

2

25 Random Things About Me

There is a meme going around Facebook where everyone is writing 25 random things about themselves.  I thought I would share this on my blog as well.  So without further ado, here are some random facts about me:   1. I get really annoyed when people spell my name wrong. In case you are not…

0

Are Software Developers Really Engineers?

A few co-workers and I lately have been having this conversation.  The following hypothetical argument illustrates the con of the argument: How can we be engineers if we can’t agree on what we’re building? Do engineers have conversations like this: Engineer 1: “It’s a bridge.” Engineer 2: “No, it’s a span.” Engineer 1: “Die, heretic!”…

19

Dynamic Expression Trees

I have been working on a project that uses the Entity Framework as the persistence store.  I am implementing a global search capability that returns results from the various entities that have a string property that start with a given query string.  So I started out with  writing code for each entity that did something…

3

Visual Studio Unit Testing Extensions v1.0.0.0 – Continued…

Last night I wrote a post about the Visual Studio Unit Testing Extensions that I put out on CodePlex.  I forgot to mention one of my favorite features that the library provides. I showed how you can use the library to write readable unit tests like the following: [TestMethod] public void NewWay_Test() { int number…

1

Visual Studio Unit Testing Extensions v1.0.0.0

This is a personal hobby project that I have been working on recently.  The code has been released on CodePlex and can be found here. The Visual Studio Testing Extensions is a library that exposes a set of extension methods to provide a way to write more readable unit tests in the Visual Studio Unit…

7