Click here to Skip to main content
15,906,645 members
Home / Discussions / C#
   

C#

 
QuestionWhich componenets to register in deployment projects Pin
wasife16-Nov-06 6:41
wasife16-Nov-06 6:41 
QuestionSelect a node in a treeView using Mouse Right Click Pin
h@s@n16-Nov-06 6:23
h@s@n16-Nov-06 6:23 
AnswerRe: Select a node in a treeView using Mouse Right Click Pin
Judah Gabriel Himango16-Nov-06 6:40
sponsorJudah Gabriel Himango16-Nov-06 6:40 
QuestionCOM interop threading problem Pin
Emad Attia16-Nov-06 5:53
Emad Attia16-Nov-06 5:53 
AnswerRe: COM interop threading problem Pin
Judah Gabriel Himango16-Nov-06 6:35
sponsorJudah Gabriel Himango16-Nov-06 6:35 
GeneralRe: COM interop threading problem Pin
Emad Attia16-Nov-06 6:55
Emad Attia16-Nov-06 6:55 
QuestionHow to run custom code when List.Add or List.Remove is running Pin
Chris Richner16-Nov-06 5:38
Chris Richner16-Nov-06 5:38 
AnswerRe: How to run custom code when List.Add or List.Remove is running Pin
Judah Gabriel Himango16-Nov-06 6:29
sponsorJudah Gabriel Himango16-Nov-06 6:29 
Rather from inheriting from List<T>, have your class implement IList<T>, and keep a List<T> field in your class. Something like this:

public class MyCollection<T> : IList<T>
{
    readonly List<T> list = new List<T>();

    public void Add(T item)
    {
        item.Owner = _owner;
        list.Add(item);
    }

    ....
}


Of course, for you to set the Owner property of the item, there must be a constraint on your T class type. You could accomplish this like this:

interface IOwnable
{
    CollectionOwner Owner { get; set; }
}


The tell your MyCollection object that only IOwnable objects can be stored in it.

class MyCollection<T> : IList<T>
     where T : IOwnable
{
    ...
}


*edit* alternately, as Daniel said, inheriting from the System.Collections.ObjectModel.Collections would require less work. You'll still need the IOwnable constraint if you want to set the owner on the items.


Tech, life, family, faith: Give me a visit.
I'm currently blogging about: God-as-Judge, God-as-Forgiver
The apostle Paul, modernly speaking: Epistles of Paul

Judah Himango


AnswerRe: How to run custom code when List.Add or List.Remove is running Pin
Daniel Grunwald16-Nov-06 7:43
Daniel Grunwald16-Nov-06 7:43 
AnswerRe: How to run custom code when List.Add or List.Remove is running Pin
Chris Richner16-Nov-06 8:49
Chris Richner16-Nov-06 8:49 
QuestionSending Email Message Pin
zaboboa16-Nov-06 5:33
zaboboa16-Nov-06 5:33 
AnswerRe: Sending Email Message Pin
ednrgc16-Nov-06 6:15
ednrgc16-Nov-06 6:15 
QuestionGetting default namespace name Pin
Zoltan Balazs16-Nov-06 5:08
Zoltan Balazs16-Nov-06 5:08 
AnswerRe: Getting default namespace name Pin
led mike16-Nov-06 5:26
led mike16-Nov-06 5:26 
GeneralRe: Getting default namespace name Pin
Zoltan Balazs16-Nov-06 7:15
Zoltan Balazs16-Nov-06 7:15 
AnswerRe: Getting default namespace name Pin
Daniel Grunwald16-Nov-06 7:44
Daniel Grunwald16-Nov-06 7:44 
GeneralRe: Getting default namespace name Pin
Zoltan Balazs16-Nov-06 8:32
Zoltan Balazs16-Nov-06 8:32 
QuestionPower Notation Pin
demetriou16-Nov-06 5:06
demetriou16-Nov-06 5:06 
AnswerRe: Power Notation Pin
User 665816-Nov-06 6:05
User 665816-Nov-06 6:05 
AnswerRe: Power Notation Pin
ednrgc16-Nov-06 6:28
ednrgc16-Nov-06 6:28 
Questiondataset Pin
fmardani16-Nov-06 4:26
fmardani16-Nov-06 4:26 
AnswerRe: dataset Pin
albCode16-Nov-06 4:32
albCode16-Nov-06 4:32 
AnswerRe: dataset Pin
Drew McGhie16-Nov-06 9:35
Drew McGhie16-Nov-06 9:35 
QuestionSockets overflowing? Pin
hammerstein0516-Nov-06 4:08
hammerstein0516-Nov-06 4:08 
AnswerRe: Sockets overflowing? Pin
Martin#16-Nov-06 4:28
Martin#16-Nov-06 4:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.