Posts under C#

Managed Extensibility Framework – Part 3 : Importing Constructor

It’s MEF time again! This time I am going to discuss a little bit about the ImportConstructor attribute. As the name of the attribute suggests, it is used to “import” dependencies in to constructor parameters. Consider the following snippet which demonstrates this. Code listing: ComplexOp implements the IComplexOp contract. The constructor for ComplexOp “imports” the [...]

Managed Extensibility Framework – Part 2 : Metadata

I am back with more MEF! This time I am discussing about metadata that could provide additional information about components the implement contracts. These entries about MEF are more of the “journal” kind rather than a “tutorial”. To provide metadata you just need to use the ExportMetadata attribute. There are two possible ways by which [...]

A Refresher/Crash Course on MEF!

Here I am with another post! This is supposed to be a crash course or a refresher (call it whatever you want!) on MEF (Managed Extensibility Framework). Consider the following gist. In order to create a fairly simple yet meaningful application that demonstrates MEF, you need 3 projects within a solution. Obviously, this is not [...]

Fun With Generics 3: IConvertible and More!

It has been a long time since I wrote anything at all in my blog and I kind of missed it! So here we go! This post is going to be about generics (again)! I wanted to create a method that converts a set of strings (attributes of an element, xml) and did indeed create [...]

Ninject: Passing dynamic parameters to the constructor

Hello poeple! Been a really long time since I posted anything. But, here you go! This is a very interesting snippet about passing dynamic arguments to constructor that will be injected to a controller (say), using ninject. When you register a dependency in ninject, you do the following: kernel.Bind<IData>().To<Data>(); Whereas, if you also want to [...]

Fun With Generics 1: Equality Comparers

Hello People! I am back with an interesting post, but this is going to be short. I was bored and was thinking up something and it occurred to me that I could just start playing around with generics So I thought I may post a series of entries regarding stuff I get to do. In [...]

Custom ConfigSection: An Alternarnative to appSettings

Hello people! I am back with yet another interesting post about something very interesting in ASP.Net – custon configuration sections. Those of you who are familiar with ASP.Net web development will be aware various sections in web.config such as <appSettings /> and <connectionStrings />. These “sections” are supported ASP.Net itself and thus we are able [...]

Custom Metadata Attributes in ASP.Net MVC

Hello! It’s been a long time since I posted anything and trust me it does not feel good So here I am with an interesting post! This post discusses about how I put custom metadata attributes in to use for describing static information for a certain field. I was in a situation where in I [...]