CSDN博客

img 2002pine

Design Pattern 7-proxy

发表于2004/9/25 17:18:00  748人阅读

using System;

namespace Pattern
{
 public abstract class subject
 {
  public abstract void request();
 }
 /// <summary>
 /// Summary description for Class1.
 /// </summary>
 public class proxy:subject
 {
  public proxy()
  {
   //
   // TODO: Add constructor logic here
   //
  }
  private readsubject rs=new readsubject();
  public override void request()
  {
            before();
   rs.request();
   after();
  }
  private void before()
  {
   System.Console.WriteLine("proxy subject before request");
  }

  private void after()
  {
   System.Console.WriteLine("proxy subject after request");
  }

 }
 
 public class readsubject:subject
 {
  public  readsubject()
  {
  }
  public override void request()
  {
   System.Console.WriteLine("real subject request");
  }

 }
}


   //代理模式
   subject s=new proxy();
   s.request();

阅读全文
0 0

相关文章推荐

img
取 消
img