Most dependency injection frameworks support some kind of object initialization through parameterized constructors. The question is whether or not it’s a good idea to use that feature of DI frameworks.
Consider the following code:
Read more…
MEF (Managed Extensibility Framework) is an awesome framework that allows easily loading types at runtime making your apps plugin-ready. Using reflection magic, MEF makes it super easy for any app to accept plugins.
Following are 5 easy steps involved in making your app plugin-ready using MEF:
- Define an interface for plugins. This is the interface that each plugin must implement.
- Define a metadata interface. This interface tells your app out of so many plugins which one is the correct plugin for a given piece of functionality.
- Define one or more concrete plugin classes.
- Decorate each class with some attributes.
- In your app write a few lines of code to invoke MEF, and let the magic happen.
Read more…
LINQ provides a Distinct() method, but in order to find distinct elements in a list of some target class, we must first implement the IEqualityComparer<T> interface in our target class. That’s what Distinct() uses in order to compute whether one element is the same as another element. Implementing IEqualityComparer<T>, however, is not so straightforward as it requires us to override Equals() and GetHashCode() methods. Most of the times if all we need to do is just to find non-duplicated elements in a given list, IEqualityComparer<T> route seems like an overkill. Read more…
I just released a new version of open source Texticize. Texticize is an extensible and intuitive object-to-text template engine for .NET. You can use Texticize to quickly create dynamic e-mails, letters, source code, or any other structured/unstructured text documents using predefined text templates substituting placeholders with properties of CLR objects at run-time.
Check it out on CodePlex at Texticize