PC Review


Reply
Thread Tools Rate Thread

Creating attribute for a collection.

 
 
CSharper
Guest
Posts: n/a
 
      14th Oct 2008
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,
 
Reply With Quote
 
 
 
 
William Stacey
Guest
Posts: n/a
 
      14th Oct 2008
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();
}
....

"CSharper" <(E-Mail Removed)> wrote in message
news:ef3581dd-9cf5-4b4b-8f9c-(E-Mail Removed)...
> 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,


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Creating XML attribute children =?Utf-8?B?TWlrZTk5MDA=?= Microsoft C# .NET 1 15th Apr 2006 02:35 PM
Creating a new collection from an existing collection marcus.wade@smart-rs.com Microsoft VB .NET 5 8th Aug 2005 05:47 PM
Creating a new collection from an existing collection marcus.wade@smart-rs.com Microsoft VB .NET 2 3rd Aug 2005 12:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:51 AM.