Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class A
- {
- public List<B> Bs { get; private set;}
- public void AddB(B b)
- {
- Bs.Add(b);
- }
- public void RemoveB(B b)
- {
- Bs.Remove(b);
- }
- public int DoWork()
- {
- // Need details of B
- // Probably need to inject a service that gets B details...
- }
- }
- public class B
- {
- public A A1 { get; private set; }
- public A A2 { get; private set; }
- public B(A a1, A a2)
- {
- A1 = a1;
- A2 = a2;
- }
- public void ChangeA1(A a1)
- {
- A1.RemoveB(this);
- A1 = a1;
- A1.AddB(this);
- }
- public void ChangeA2(A a2)
- {
- A2.RemoveB(this);
- A2 = a2;
- A2.AddB(this);
- }
- }
Add Comment
Please, Sign In to add comment