static IList <IFizzBuzz> GetConcretClassesIV() { List <IFizzBuzz> instances = new List <IFizzBuzz>(); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); Type[] types = assembly.GetTypes(); foreach (Type type in types) { // Does this class support the transport interface? Type typeExample = type.GetInterface("IFizzBuzz"); if (typeExample == null) { // Not supported. continue; } // This class supports the interface. Instantiate it. IFizzBuzz example = assembly.CreateInstance(type.FullName) as IFizzBuzz; if (example != null) { // Successfully created the interface. We are done. instances.Add(example); } } return(instances); }
static bool DoTheJob(IFizzBuzz obj, int i) { IWriter w = null; string description = string.Empty; obj.Number = i; if (obj.Check()) { w = new WriteOnConsole(obj); w.Write(); return(true); } return(false); }
/// <summary> /// Constructor for new solution. /// </summary> /// <param name="solution">Solution.</param> public Context(IFizzBuzz solution) { _fizzBuzzSolution = solution; _stopWatch = new Stopwatch(); }
/// <summary> /// Changing current solution in context. /// </summary> /// <param name="solution">New solution to set context.</param> public void SetSolution(IFizzBuzz solution) { _fizzBuzzSolution = solution; _stopWatch.Reset(); }
public WriteOnConsole(IFizzBuzz obj) { _obj = obj; }