Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 /// <summary>
 /// Constructor for new solution.
 /// </summary>
 /// <param name="solution">Solution.</param>
 public Context(IFizzBuzz solution)
 {
     _fizzBuzzSolution = solution;
     _stopWatch        = new Stopwatch();
 }
Esempio n. 4
0
 /// <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();
 }
Esempio n. 5
0
 public WriteOnConsole(IFizzBuzz obj)
 {
     _obj = obj;
 }