Design mode-prototype (Prototype) mode

Source: Internet
Author: User

Writing these may be thought of as "pattern-mode". Insus.net thought that every master might have to do it before he became a master.

Walk, began to learn from childhood, until now, who is not to walk to walk? Always repeating ...

Many people do not share their experience, share their own process, share this thing, it will not be because of sharing less ...

Touched by the story, because of the sharing of the course and let people moved ...

Design patterns, in the ASP. NET development process, indeed a lot of environmental applications, perhaps only because of time and efficiency problems, the use of the most direct method to solve. Often brought about by the maintenance of complex becomes difficult to carry out.

To enter the subject, first look at this article "mouse click, copy the GridView Control data row" http://www.cnblogs.com/insus/p/3680461.html the user click on the row to copy. In fact, its implementation of the method is to filter the original data.

In the prototype design pattern, the original object is cloned.

Declaring an abstract class or interface, in which one method is to clone itself:


Create a container that stores all the processed objects:


The actual object is to be implemented as a prototype abstract class:


Here is the copy of the object when the row is clicked:


Final Result:

The above method, select the row, copy one, if the selection is saved up:

Demo, this time, just a little bit, just copy one:

However, perhaps what you need is to click on a clone once, once selected, no longer stored:

Real-time demo, no matter how many times you choose, only one object is stored:

Source code Download:
Http://download.cnblogs.com/insus/CSharpNET/prototype_pattern.rar

Design mode-prototype (Prototype) mode

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.