Click here to Skip to main content
15,890,897 members
Home / Discussions / C#
   

C#

 
GeneralRe: Checking the fail status of windows service Pin
dan!sh 19-Mar-09 7:45
professional dan!sh 19-Mar-09 7:45 
GeneralRe: Checking the fail status of windows service Pin
Jimmanuel19-Mar-09 8:07
Jimmanuel19-Mar-09 8:07 
GeneralRe: Checking the fail status of windows service Pin
dan!sh 19-Mar-09 8:12
professional dan!sh 19-Mar-09 8:12 
QuestionGeneric Change Event handler Pin
dwolver19-Mar-09 5:16
dwolver19-Mar-09 5:16 
AnswerRe: Generic Change Event handler Pin
DaveyM6919-Mar-09 5:40
professionalDaveyM6919-Mar-09 5:40 
GeneralRe: Generic Change Event handler Pin
dwolver19-Mar-09 6:02
dwolver19-Mar-09 6:02 
GeneralRe: Generic Change Event handler Pin
DaveyM6919-Mar-09 6:17
professionalDaveyM6919-Mar-09 6:17 
GeneralRe: Generic Change Event handler Pin
S. Senthil Kumar20-Mar-09 4:00
S. Senthil Kumar20-Mar-09 4:00 
Not without a lot of work, I'm afraid.

With a class like
class NotifiableProperty<T>
{
    T val;
    public event Action PropertyChanged;

    public T Value
    {
        get { return val; }
        set { val = value; PropertyChanged(); }
    }

    public static implicit operator T(NotifiableProperty<T> p)
    {
        return p.Value;
    }
}


you can do
class MyClass
    {
        NotifiableProperty<int> p = new NotifiableProperty<int>();

        public MyClass()
        {
            p.PropertyChanged += new Action(() => Console.WriteLine("Changed"));
        }

        public int P
        {
            get { return p; }
            set { p.Value = value; }
        }
    }


and then when you do

MyClass m = new MyClass();
m.P = 20;


you will see "Changed" printed on the screen.

I don't know how to automatically hook to the events, and I don't think setting up events from the base class is a good idea, as there is the possibility that derived class members wouldn't have been initialized at that point. Maybe use reflection inside the derived class?

Regards
Senthil [MVP - Visual C#]
_____________________________
My Home Page |My Blog | My Articles | My Flickr | WinMacro

AnswerRe: Generic Change Event handler Pin
dwolver19-Mar-09 6:17
dwolver19-Mar-09 6:17 
QuestionPrint multipage tiff images Pin
Deabdy2119-Mar-09 4:58
Deabdy2119-Mar-09 4:58 
GeneralRe: Print multipage tiff images Pin
Qwerty190621-Apr-10 3:21
Qwerty190621-Apr-10 3:21 
AnswerRe: Print multipage tiff images Pin
Deabdy2121-Apr-10 3:38
Deabdy2121-Apr-10 3:38 
GeneralRe: Print multipage tiff images Pin
reaperx905-Jul-11 3:57
reaperx905-Jul-11 3:57 
QuestionSave WebCam Capture with a resulution of 2MP Pin
nukebold19-Mar-09 4:55
nukebold19-Mar-09 4:55 
AnswerRe: Safe WebCam Capture with a resulution of 2MP Pin
musefan19-Mar-09 4:57
musefan19-Mar-09 4:57 
AnswerRe: Save WebCam Capture with a resulution of 2MP Pin
Dave Kreskowiak19-Mar-09 8:26
mveDave Kreskowiak19-Mar-09 8:26 
GeneralRe: Save WebCam Capture with a resulution of 2MP Pin
nukebold19-Mar-09 8:45
nukebold19-Mar-09 8:45 
GeneralRe: Save WebCam Capture with a resulution of 2MP Pin
Dave Kreskowiak19-Mar-09 11:01
mveDave Kreskowiak19-Mar-09 11:01 
Questionconvert class to dll Pin
sanforjackass19-Mar-09 4:42
sanforjackass19-Mar-09 4:42 
AnswerRe: convert class to dll Pin
DaveyM6919-Mar-09 4:44
professionalDaveyM6919-Mar-09 4:44 
GeneralRe: convert class to dll Pin
sanforjackass19-Mar-09 5:39
sanforjackass19-Mar-09 5:39 
AnswerRe: convert class to dll Pin
musefan19-Mar-09 4:44
musefan19-Mar-09 4:44 
AnswerRe: convert class to dll Pin
Cracked-Down19-Mar-09 5:29
Cracked-Down19-Mar-09 5:29 
QuestionSend an email witch c# Pin
abbd19-Mar-09 4:32
abbd19-Mar-09 4:32 
AnswerRe: Send an email witch c# Pin
Xmen Real 19-Mar-09 4:35
professional Xmen Real 19-Mar-09 4:35 

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.