Using Ninject for the Builder Pattern

Jan 30, 2015 at 9:13 PM
http://stackoverflow.com/questions/8585325/inject-different-classes-that-implement-the-same-interface-using-ninject/8585474#8585474

In reference to the above article, I'm not completely sure the answer that was provided is any different from using a switch-case like this:

switch (chartBuildType)
case : Temperature
director = new ChartDirector(new TemperatureChartBuilder());
break;

How can I use contextual binding to get a different implementation based on user input at runtime?
Jan 30, 2015 at 9:56 PM
I understood the solution from the stack overflow now.

kernel.Get<IChatBuilder>("TemperatureChartBuilder") doesnt necessarily need to be hard-coded. But before calling the the ChartDirector, this could be done as follows:

director = new ChartDirector(kernel.Get<IChartBuilder>(String.Format("{0}Builder", ChartTypeEnum.ToString())))