• compositephotolibrary.cs


      using System;
      using System.Collections.Generic;
      using System.IO;
      using CompositePattern;

      //  Composite Pattern    Judith Bishop August 2007
      //  The pattern is generic, and an example is given for a real world client
     
      // The Client
      class CompositePatternExample {
        static void Main () {
          IComponent <string> album = new Composite<string> ("Album");
          IComponent <string> point = album;
          string [] s;
          string command, parameter;
          // Create and manipulate a structure
          StreamReader instream = new StreamReader("composite.dat");
          do {
            string t= instream.ReadLine();
            Console.WriteLine("\t\t\t\t"+t);
            s = t.Split();
            command = s[0];
            if (s.Length>1) parameter = s[1]; else parameter = null;
            switch (command) {
              case "AddSet"   :   
                IComponent <string> c = new Composite <string> (parameter);
                point.Add(c);
                point = c;
                break;
              case "AddPhoto":  point.Add(new Component <string> (parameter)); break;
              case "Remove"   : point = point.Remove(parameter); break;
              case "Find"        : point = album.Find(parameter);  break;
              case "Display"    : Console.WriteLine(album.Display(0));  break;
              case "Quit"        : break;
            }

          } while (!command.Equals("Quit"));
        }
      }
     


  • 相关阅读:
    大数据笔记
    关于服务器编程的笔记
    [转] IPC之管道、FIFO、socketpair
    一些公司链接
    Delphi 通过字符串实例化类
    Delphi根据字符串实例化对象
    Class-reference types 类引用类型--快要失传的技术
    GETCLASS与REGISTERCLASS的应用一例
    Delphi XE增强的RTTI妙用--动态创建包中的窗口类
    Delphi2010的RTTI增强
  • 原文地址:https://www.cnblogs.com/shihao/p/2496301.html
Copyright © 2020-2023  润新知