Design Patterns http www devbg orgpatternscourse Memento Pattern
Design Patterns http: //www. devbg. org/patternscourse Memento Pattern Галин Илиев MCSD. NET iliev@galcho. com TSCG www. wordassist. com
Примерна реализация public abstract class Memento. Base { public abstract Memento. Base Set. State(object State); public abstract object Get. State(); } class Sales. Prospect { private class Memento : Memento. Base { public override object Get. State() { Array. List al = new Array. List(3); al. Add(this. name);
Примерна реализация al. Add(this. phone); al. Add(this. budget); return al; } public override Memento. Base Set. State(object state) { Array. List al = (Array. List)state; if (al. Count != 3) throw new Argument. Exception("State doesn't have expected number of members!", "state"); this. name = al[0]. To. String(); this. phone = al[1]. To. String(); this. budget = double. Parse(al[2]. To. String()); return this; }
- Slides: 17