Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Responsible for the relation
- public class Foo
- {
- List<Bar> Bars = new List<Bar>();
- public void AddBar(Bar bar)
- {
- Bars.Add(bar);
- bar.AddFoo(this);
- }
- }
- public class Bar
- {
- List<Foo> Foos = new List<Foo>();
- // This shouldn't exist.
- public void AddFoo(Foo foo)
- {
- Foos.Add(foo);
- foo.AddBar(this); // Inf Recursion
- }
- }
- public class Foo
- {
- private IList<Bar> Bars {get;set;}
- public void AddBar(Bar bar)
- {
- Bars.Add(bar);
- bar.Foos.Add(this);
- }
- }
- public class Bar
- {
- internal IList<Foo> Foos {get;set;}
- }
- protected Set getEvents() {
- return events;
- }
- protected void setEvents(Set events) {
- this.events = events;
- }
- public void addToEvent(Event event) {
- this.getEvents().add(event);
- event.getParticipants().add(this);
- }
- public void removeFromEvent(Event event) {
- this.getEvents().remove(event);
- event.getParticipants().remove(this);
- }
- DALFactory.FooAdapter.getBars(foo);
- public class Foo
- {
- List<Bar> Bars = new List<Bar>();
- public void AddBar(Bar bar)
- {
- Bars.Add(bar);
- Bar.AddFoo(bar,this);
- }
- }
- public class Bar
- {
- List<Foo> Foos = new List<Foo>();
- // This shouldn't exist.
- public static void AddFoo(Bar bar, Foo foo)
- {
- bar.Foos.Add(foo);
- //foo.AddBar(this); inf recurtion
- }
- }
Add Comment
Please, Sign In to add comment