Design Mode-Prototype and prototype

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.