Creating attribute for a collection.

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,
 
W

William Stacey

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();
}
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top