public void Subscribe(StudentCollection <TKey> a) { a.StudentsChanged += ((source, e) => { var note = new JournalEntry(e.NameCollection, e.Info, e.PropertyName, e.Key.ToString()); m_st.Add(note); }); }
static void Main(string[] args) { // 1. Create Collections var a = new StudentCollection <int>((e) => e.Id, "a"); var b = new StudentCollection <int>((e) => e.Id, "b"); // 2. Journal and Subscribe var j = new Journal <int>(); j.Subscribe(a); j.Subscribe(b); // 3. Change Collections var s1 = new Student(Education.Bachelor, 8); var s2 = new Student(Education.Bachelor, 8); a.AddStudents(s1); b.AddStudents(s2); s1.Educ = Education.SecondEducation; s2.Educ = Education.SecondEducation; s1.Group = 4; s2.Group = 4; a.Remove(s1.Id); b.Remove(s2.Id); s1.Educ = Education.Specialist; s2.Educ = Education.Specialist; s1.Group = 3; s2.Group = 3; // 4. Journal in Console // After deleting from Collections changing not write in journal Console.WriteLine(j.ToString()); }