Design Mode-Prototype and prototype
Some people may think that "pattern is used for mode ". As Insus. NET thinks, every master may have to do so before becoming a master.
Walking, learning from an early age, till now, who is not walking to walk? Keep repeating ......
Many people do not share their own experiences, share their own processes, and share such things. It will not become less because of sharing ......
The story is touching because of sharing the course ......
The design pattern, in the process of ASP. NET development, many environment applications are indeed obtained, maybe only because of time and efficiency issues, the most direct method is used to solve. It is often difficult to carry out complicated maintenance.
Enter the topic, first take a look at this Mouse click, copy the data row of the GridView control http://www.cnblogs.com/insus/p/3680461.html user click to copy. In fact, its implementation method is to filter the original data.
In the prototype design mode, the original object is cloned.
Declare an abstract class or interface. One of the methods is to clone yourself:
Create a container to store all processed objects:
The actual object must be a prototype abstract class:
The following figure shows how to copy an object when a row is clicked:
Final result:
In the above method, select a row and copy one. If you save all the selected rows:
In this demonstration, just click one point to copy one:
However, you may need to click Clone once and choose not to store it again:
Real-time demonstration, no matter how many times you click, only one object is stored:
Source code download:
Http://download.cnblogs.com/insus/CSharpNET/prototype_pattern.rar