ASP.NET Web API + minimal touch MEF

Monday, November 11, 2013

ASP.NET Web API + minimal touch MEF this post will offer light touching technique of introducing MEF to ASP.NET Web API. the motivation for having MEF (or any other IoC container) for Web API is for dependencies abstraction and testability. it is also easier to design your API by Contract (mining that you don't have to think about the actual implementation at design time). so why minimal touch? even those other suggestion can be found, most of them involve custom routing. the risk of alter ASP.NET Web API routing, is...

Immutable Collections

Sunday, February 17, 2013

Immutable Collections Immutability is a pattern which is suit well parallel programming, but you have to be aware of a potential memory pressure risk when it's not implemented right or used wisely. this post will cover a new BCL library (still in its preview stage) which is targeting immutable collections. .NET is already having Concurrent implementation for Queue, Stack, Bug and Dictionary, which is thread-safe, but other type of collection like List is missing. another type of collection are read only collection, but those type...

MEF 2.0 – mini series: part 8 (Composition options and exception handling)

Saturday, February 16, 2013

MEF 2.0 - mini series: part 8 (Composition options and exception handling) this is the last post in the MEF 2.0 mini series. you can see other posts of this series in here. this post will wrap-up the series with a quick survey to to the to some changes made for the underline composition process. Exception one of the most painful experience of MEF 1 was its misleading exception's description. some time it was really hard to figure out the exception roots.  you can read more about MEF...

MEF 2.0 – mini series: part 6 (Composition scoping and lifetime management)

Wednesday, January 16, 2013

MEF 2.0 - mini series: part 6 (Composition scoping and lifetime management) this is the 6th post in the MEF 2.0 mini series. you can see the following TOC for other posts in this series. in this post I will cover a new concept of scoping and part lifetime management, which is a great improvement over MEF 1. MEF 1 was coming with a fairly naïve lifetime management. part's lifetime could be either shared or non-shared (you could also apply 'any' but eventually 'any'...

MEF 2.0 – mini series: part 5 (Fluent export properties)

Tuesday, January 15, 2013

MEF 2.0 - mini series: part 5 (Fluent export properties) this is the 5th post in the MEF 2.0 mini series. you can see the following TOC for other posts in this series. in this post I will cover the fluent property's export. Exporting properties is a less known feature of MEF. MEF 1 was supporting this feature by using the attribute model. you could decorate a property with a attribute and then it become available for imports. the following...

MEF 2.0 – mini series: part 4 (Fluent Import)

Saturday, January 12, 2013

MEF 2.0 - mini series: part 4 (Fluent Import) this is the 4th post in the MEF 2.0 mini series. you can see the following TOC for other posts in this series. in this post I will discuss the Fluent import API. we was talking about Fluent Export and Constructor Injection in the previous posts. this post will complete the main scenarios of Import's fluent API. I will demonstrate the import technique using the following classes: Code Snippet public class Foo {     public Logger Log {...

MEF 2.0 – mini series: part 3 (Fluent import constructor)

Wednesday, January 9, 2013

MEF 2.0 - mini series: part 3 (Fluent import constructor) this is the 3rd post in the MEF 2.0 mini series. you can see the following TOC for other posts in this series. in this post I will discuss the fluent constructor injection API. Constructor Injection the following code is having a Logger and Worker class which is having 2 constructor (one has no parameters and the other is getting ILogger): Code Snippet   public class Logger: ILogger {     public void Write(string message) {...

MEF 2.0 – mini series: part 2 (Fluent and Conventional Export)

Sunday, January 6, 2013

MEF 2.0 - mini series: part 2 (Fluent and Conventional Export) this is the second post in the MEF 2.0 mini series. you can see the following TOC for more. in this post I will start to cover the fluent discovery model and the idea of discovery by convention. traditionally, out of the box, MEF come with a single discovery model, which was the Attribute model. it is true that you could extend MEF's discovery model by using either a custom catalog or a custom export provider, but...

MEF 2.0 TOC

Portable MEF (Microsoft.Composition) Part1: Attribute Model Part2: Convention Part 3: Dependency Injection vs. Service Locator Part 4: Microsoft.Composition (Portable MEF): Scoping   MEF 2.0 (Full Version) TOC MEF 2.0 is a reflection of a community requests. features like Open Generics, fluent and conventional discovery, lifetime handling of the part, better exception handling and more, was all requested by the community. part 1: Open Generics Part 2: Fluent and Conventional Export Part 3: Fluent import constructor Part 4: Fluent import Part 5: Fluent export properties. Part 6: Composition scoping and lifetime management ...

MEF 2.0 – mini series: part 1 (Open Generics)

Friday, January 4, 2013

MEF 2.0 - mini series: part 1 (Open Generics) this is the first post of a new mini series about MEF 2.0. MEF 2.0 is a reflection of a community requests. features like Open Generics, fluent and conventional discovery, lifetime handling of the part, better exception handling and more, was all requested by the community. each post of this mini series will target a single enhancement. Open Generics one of the most annoying missing feature in MEF 1 was the lack of support for Open generics. the...