Monday, May 26, 2014
Sunday, October 6, 2013
In this short video we explore how using extension methods and the CallerMemberNameAttribute can help to reduce duplicate code and remove magic strings from your code
Tuesday, August 13, 2013
Friday, June 21, 2013
Friday, January 11, 2013
I’m a big fan of MEF (Managed Extensibility Framework). I think it is very easy to use and offers a lot of advantages when developing an application. MEF was developed to be a framework to allow for extensibility in your applications. Parts of Visual Studio (including the Entity Framework Designer) run on MEF as does the Extension Manager. That being said, it also works very well as a Dependency Injection container. My goal is not to compare MEF to other containers (ie. Unity, Windsor Castle, NInject, etc) but to show you how to use MEF as a DI container.
As usual, you can view/download the code on GitHub.
For Part 1 we will create a simple console application that will log a message. However, we will use MEF as a DI container to supply the ILogger implementation. Remember, this is meant to be a very simple example. It is definitely not meant to demonstrate how MEF should be used.
Monday, June 25, 2012
Here is the database that we will be working with:
1. The Entities are imported with these names
2. Navigation Properties and References are created using these names
3. The Pluralization service can have issues figuring out what the appropriate pluralization would be
Let's begin by creating a new C# Project called EFEntityNameScrubberExtension:
Once the EI has started, create a new Console Application and add an Entity Data Model. Choose the "Generate from Database" option and click Next. Select the Sandbox database (or any database with the table prefix that we will try to create. For now, simply add a single table to the model:
In Part 2 we will dig into the meat of the extension!
You can download the source on GitHub here.
Saturday, June 23, 2012
I'd prefer to do something like this:
Here is the source for the GetAttribute extension method: