Advertisement
Guest User

Untitled

a guest
May 13th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. public class IBar
  2. {
  3.   void DoBar();
  4.   void DoBaz();
  5.   event EventHandler BarChanged;
  6. }
  7.  
  8. public abstract class BaseBar : IBar {
  9.    ... implementation ...
  10.    public abstract void DoGaz();
  11.    public virtual void DoFoo() {...}
  12. }
  13.  
  14. public class ABar : BaseBar
  15. {
  16.   ... implementation ...
  17. }
  18.  
  19. public class BBar : BaseBar
  20. {
  21.  
  22.   ... implementation ...
  23. }
  24.  
  25. public static class BarFactory
  26. {
  27.    public static IBar MakeBar(string arg) {
  28.         switch(arg) {
  29.            case "xxx":
  30.              return new ABar();
  31.            case "qqq":
  32.              return new BBar();
  33.            ... and so on ...
  34.         }
  35.    }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement