public void Execute()
    {
        FieldInfo observersField = this.jobs.GetType()
                                   .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                                   .FirstOrDefault(f => f.FieldType == typeof(List <IObserver>));

        if (observersField == null)
        {
            throw new InvalidOperationException(ObserversFieldNotFound);
        }

        List <IObserver> observers = (List <IObserver>)observersField.GetValue(this.jobs);

        foreach (IObserver observer in observers)
        {
            IObservableJob observableJob = (IObservableJob)observer;

            observableJob.PrintInfo();
        }
    }
Beispiel #2
0
    public void Execute()
    {
        IObservableJob job = this.jobFactory.CreateJob(this.jobName, this.workHoursRequired, this.employee, this.jobs, writer) as IObservableJob;

        this.jobs.Register(job);
    }