IndependentList<T>
Independent<T> is used for single values. To track dependencies on collections, use IndependentList<T>. Use this as a field whenever you want to track changes to a collection.
public class Document { private IndependentList<Person> _people = new IndependentList<Person>(); }
Expose the field as a read-only property of type IEnumerable<T>. Usually, you want your class to be in charge of what gets added to the list. IEnumerable<T> lets other classes enumerate the elements of the list, but not modify it.
public IEnumerable<Person> People { get { return _people; } }
IndependentList<T> supports all of the methods of List<T>. You can Add, Insert, Remove, etc. just as you are used to.
public Person NewPerson() { Person person = new Person(); _people.Add(person); return person; } public void DeletePerson(Person person) { _people.Remove(person); }
Any dependent properties that reference the list, even through the IEnumerable<T> interface, will take a dependency upon its contents. They will be updated when something is added to or removed from the list.
Recent comments
3 years 13 weeks ago
3 years 19 weeks ago
3 years 44 weeks ago
3 years 46 weeks ago
3 years 47 weeks ago
4 years 3 days ago
4 years 3 days ago
4 years 17 weeks ago
4 years 17 weeks ago
4 years 21 weeks ago