Click here to Skip to main content
15,916,293 members
Home / Discussions / C#
   

C#

 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius14-Jan-09 2:30
mentorWendelius14-Jan-09 2:30 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6914-Jan-09 3:25
professionalDaveyM6914-Jan-09 3:25 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius14-Jan-09 3:42
mentorWendelius14-Jan-09 3:42 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6914-Jan-09 11:41
professionalDaveyM6914-Jan-09 11:41 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius14-Jan-09 11:59
mentorWendelius14-Jan-09 11:59 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6915-Jan-09 3:13
professionalDaveyM6915-Jan-09 3:13 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius15-Jan-09 3:19
mentorWendelius15-Jan-09 3:19 
GeneralRe: Generic event, or raise event based on generic type. Pin
DaveyM6915-Jan-09 4:01
professionalDaveyM6915-Jan-09 4:01 
Well there's the base class you mentioned earlier. So far I've just done this.
public enum NotifyReasons
{
    Unspecified = 0,
    Created,
    Updated,
    Removed
}
public class NotifyArgs<T>
{
    #region Fields
    private T m_Value;
    private NotifyReasons m_Reason;
    #endregion

    #region Constructors
    public NotifyArgs(T value)
    {
        m_Value = value;
    }
    public NotifyArgs(T value, NotifyReasons reason)
    {
        m_Value = value;
        m_Reason = reason;
    }
    #endregion

    #region Properties
    public T Value
    {
        get { return m_Value; }
    }
    public NotifyReasons Reason
    {
        get { return m_Reason; }
    }
    #endregion
}
which is created by this method (all the overloads call this method)
private void Notify<T>(object source, NotifyArgs<T> a)
{
    foreach (Subscriber item in m_Subsribers)
        if (item.Type.Equals(typeof(T)))
            item.GetNotifyDelegate<T>()(source, a);
}
I haven't looked at the best way to implement this so it can be extended by the user and still passed through the notifier...

Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius15-Jan-09 10:27
mentorWendelius15-Jan-09 10:27 
GeneralRe: Generic event, or raise event based on generic type. [modified] Pin
DaveyM6915-Jan-09 23:08
professionalDaveyM6915-Jan-09 23:08 
GeneralRe: Generic event, or raise event based on generic type. Pin
Wendelius15-Jan-09 23:25
mentorWendelius15-Jan-09 23:25 
QuestionKeep current view centered on Zoom Pin
Richard Blythe12-Jan-09 7:16
Richard Blythe12-Jan-09 7:16 
AnswerRe: Keep current view centered on Zoom [modified] Pin
Luc Pattyn12-Jan-09 8:01
sitebuilderLuc Pattyn12-Jan-09 8:01 
GeneralRe: Keep current view centered on Zoom Pin
Richard Blythe12-Jan-09 9:10
Richard Blythe12-Jan-09 9:10 
QuestionAddress Pin
boiDev12-Jan-09 6:56
boiDev12-Jan-09 6:56 
AnswerRe: Address Pin
EliottA12-Jan-09 7:21
EliottA12-Jan-09 7:21 
GeneralRe: Address Pin
boiDev12-Jan-09 11:25
boiDev12-Jan-09 11:25 
GeneralRe: Address Pin
EliottA12-Jan-09 11:29
EliottA12-Jan-09 11:29 
GeneralRe: Address Pin
boiDev12-Jan-09 11:43
boiDev12-Jan-09 11:43 
GeneralRe: Address Pin
EliottA12-Jan-09 12:28
EliottA12-Jan-09 12:28 
Questionincreasing panel size Pin
jananiSreedhar12-Jan-09 6:11
jananiSreedhar12-Jan-09 6:11 
AnswerRe: increasing panel size Pin
User 665812-Jan-09 6:18
User 665812-Jan-09 6:18 
AnswerRe: increasing panel size Pin
EliottA12-Jan-09 6:23
EliottA12-Jan-09 6:23 
QuestionString in UTF-8 format was inserted to DB Pin
Miro7712-Jan-09 5:44
Miro7712-Jan-09 5:44 
AnswerRe: String in UTF-8 format was inserted to DB Pin
Ben Fair12-Jan-09 8:06
Ben Fair12-Jan-09 8:06 

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.