MEF – Conventional catalog for registering non-attributed parts

October 18, 2010

As part of the task where I had to upgrade an existing WPF project to PRISM 4.0 and work with MEF, one of the requirements was to support registering existing non-attributed parts. Consider the following example - Code Snippet public interface IFoo { }   public class Foo : IFoo { }   static void Main(string args) {     //This is the desired thing to do     myCatalog.Register<IFoo, Foo>(); } As you can see, type Foo has no export definitions set on it. One...
tags: ,
no comments

MEF – Runtime Type Catalog, support multi registrations in runtime

October 17, 2010

Recently, I dug deep into MEF because I was involved in a project where there was a decision to upgrade the WPF client to PRISM 4 and advance to using MEF alone instead of Unity. While many argue that MEF isn’t yet a full DI framework, it still provides an easy way to enable application extensibility in your projects. One of the tasks that I had while upgrading the client to PRISM 4, is to keep supporting type registration in runtime, something in the sort of the following - Code Snippet ...
tags: ,
no comments

Localize DayOfWeek Enum

October 12, 2010

If you have a DateTime and you would like to get the localized name of the day according to the current culture, you can just do the following - myDateTime.ToString(“ddd”); I had a different scenario though, I had an object with a property of DayOfWeek enum which represents week days. I needed to display just that property in my UI as a localized string. In this case, I don’t have a DateTime so I can’t use its culture-based string formatting, so I can’t use the approach written above. ...
tags: ,
2 comments

WPF – ComboView – ComboBox with a TreeView

October 10, 2010

Update 26/09/2011 - There is an issue with the control where the entire tree is loaded, which may affect performance and memory allocation when working with many items. Unfortunately, I don’t think I would be able to fix that any time soon. A few years back, I built a WPF control that I decided to share here now. The control is called ComboView – A ComboBox showing a TreeView inside to display hierarchical data (you can use it for flat data if you need its features though). The control provides some really nice built-in...
tags: ,
19 comments

WCF Contrib – Your own base Client Channel Classes

One of the core components in WCF Contrib is the ‘ClientChannel’ which handles the client side proxy creation and management, allowing you to easily call services, with the addition of environment support, using using, and comprehensive behaviors extensions model. Currently, the built-in Client Channels can be instantiated with a configuration name which it loads the ChannelFactory with. A common question is, how can you use the Client Channel if you like to instantiate the ChannelFactory in code. The way to do that is to inherit from ClientChannel and override ‘CreateChannelFactoryCore’ and just return the ChannelFactory...
no comments