Home > Net > C # about event handling method name by default
C # about event handling method name by default
Time:11-14
Consult: custom Tester, a class which defines an event: StateChanged, new a Tester in the Form1, and +=registered StateChanged events, tip the default event handler method is called: Form1_StateChanged, that is to say the Tab after out from under the two methods for Form1_StateChanged, how to make the default method called Tester_StateChanged, rather than having to manually change each time, thank you
CodePudding user response:
Is not necessary, Forn1 don't know where you want to register the name of the function is coming from, the most reasonable, of course, is a function of their class definition (namely the default function prefix for Form1, it won't cause misunderstanding),
CodePudding user response:
CodePudding user response:
This may need to buy Microsoft. After all, "every time don't have to manually change" demand can every programmer can come up with dozens of all tastes.
CodePudding user response:
In fact, I think the.net can be modified in the configuration, even with the dynamic injection directly too much and too often, cause a variety of underlying technology debate, has a small white with other technical system competition caused the bad influence, under the past vs always provide the framework of relatively simple and straightforward a good dental laboratories test, the default parameters of medium to high, and basically don't make changes (to change will have to manually modify the registry), quite good,
In fact you can choose more concise programming concept, such as anonymous, explicit delegate, such as
You want to name the process, you first "independent" with the process object,
CodePudding user response:
Change can change, such as we use the Resharp myself definition template
But in fact it is not recommended, suppose I have two controls, and then,
Do you think I should write Object1_load Object2_load
Should be written Form1_load1 form1_load2
CodePudding user response:
Yes, process belongs to Form1 rather than Tester, this name can explain the concept of the lz for events still have mistake,
On type Tester belong to define events, then the event interface definitions in Tester, trigger Tester, this Tester is a service, and Form1 is a host (client), is Form1 defines the processing process, the Tester only defines the interface specification,
CodePudding user response:
If you are in the new after a Tester, a host program need respectively articulated for it two or three processing, you use "press Tab twice" still can't generate, you have to write +=... This code, so don't tangle vs tools, syntax in c # to create some code style, it is good,
CodePudding user response:
A great trouble to do,
First of all, you need to understand how to extend VisualStudio, can read: [start developing Visual Studio extension] https://docs.microsoft.com/zh-cn/visualstudio/extensibility/starting-to-develop-visual-studio-extensions? View=v - 2019
Then, to understand the Designer host design architecture, such as can be read (marked as dotnet2.0, but the concept is the same) : [The Create And Host The Custom Designers have The The.net Framework 2.0] https://docs.microsoft.com/en-us/archive/msdn-magazine/2006/march/create-and-host-custom-designers-with-the-net-framework-2-0
You can then by implementing IEventBindingService interface, and the custom of CreateUniqueMethodName , as you want to according to your rules of incident response function name,
Finally, install your Visual Studio extension development, from then on, enjoy "every time don't have to manually change" happiness; -)