-
-
Save jchannon/3076667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace NinjectTest | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
public class Action : IGenre | |
{ | |
public string GetTopTenMoviesInGenre() | |
{ | |
return "Die Hard,Raiders of the Lost Ark,Aliens,Mad Max,Terminator,Matrix,Lethal Weapon,Robocop,Bourne Ultimatum,Enter the Dragon"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace NinjectTest | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
public class Comedy : IGenre | |
{ | |
public string GetTopTenMoviesInGenre() | |
{ | |
return "Animal House,Rushmore,Beveley Hills Cop,Groundhog Day,Shaun of the Dead,South Park,Dr Strangelove,Blazing Saddles,Anchorman,Horrible Bosses"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IGenreFactory | |
{ | |
IGenre GetHorror(); | |
IGenre GetAction(); | |
IGenre GetComedy(); | |
} | |
public class GenreFactory : IGenreFactory | |
{ | |
private IKernel kernel; | |
public GenreFactory(IKernel kernel) | |
{ | |
this.kernel = kernel; | |
} | |
public virtual IGenre GetHorror() | |
{ | |
return kernel.Get<Horror>(); | |
} | |
public virtual IGenre GetAction() | |
{ | |
return kernel.Get<Action>(); | |
} | |
public virtual IGenre GetComedy() | |
{ | |
return kernel.Get<Comedy>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace NinjectTest | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
public class Horror : IGenre | |
{ | |
public string GetTopTenMoviesInGenre() | |
{ | |
return "Friday the 13th,Scream,Dracula,The Haunting,Suspiria,Dawn of the Dead,The Thing,The Fly,Poltergeist,The Ring"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace NinjectTest | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
public interface IGenre | |
{ | |
string GetTopTenMoviesInGenre(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass | |
{ | |
private IGenre Genre; | |
public MyClass(IGenre Genre) | |
{ | |
this.Genre = Genre; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment