简体   繁体   中英

Visual Studio 2019 Automatic Event Handlers Generation

Is it at all possible to generate handlers for ALL events object has to offer in a similar way you can do it for a single event simply by pressing tab tab after +=?

if not Visual Studio, any other IDE that can do that?

Yes I understand that. It's not what I am asking. I need I way to quickly generate these handlers.

I have one way for you. Obviously, this solution will not meet your needs i 100%, but you can try it. You can create an interface with all methods from a known object and inherit it. Now you can implement this interface. Unfortunately, you need to add an event handler to the constructor.

class myObject:IMyObject {

    Public myObject() //this you have to add
    {
        this.my_Event += onMy_EventHandled();
        this.my_Event1 += onMy_EventHandled1();
    }

    //this section will be create automatically        
    void onMy_EventHandled()
    {
    }
        
    void onMy_EventHandled2()
    {
    }
}

eg interface

interface IMyObject {
   void onMy_EventHandled();
   void onMy_EventHandled();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM