Creating attribute for a collection.

  • Thread starter Thread starter CSharper
  • Start date Start date
C

CSharper

It is a strange question;

I have a collection of Types which is derived off of IDictionary. When
ever something changes in the collection, I want to mark the
collection as changed a boolean flag. How can I do that or is it a
correct way of doing it?

public class MyType
{
}

public class TypeCollection<TValue>:IDictionary<string, TValue>
{
}

public class MyTypeCollection<TValue>:TypeCollection<TValue>
{
}

what I want to do is to set a boolean value in MyTypeCollection to
true when something changes in that collection.

Thanks,
 
you need to implement the interface and add your bool inside. This will mark
changes for add, delete. Changes to properties on the objects themselfs
would require more work.

public class MyCollection<T, T2> : IDictionary<T, T2>
{

#region IDictionary<T,T2> Members

public void Add(T key, T2 value)
{
throw new NotImplementedException();
}

public bool ContainsKey(T key)
{
throw new NotImplementedException();
}
....
 
Back
Top