Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace throwaway
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Test t = new Test();
  14.             Log l = Log.CreateInstance(t);
  15.             l.Write("this is a test");
  16.             Console.ReadLine();
  17.         }
  18.     }
  19.  
  20.     class Test : ILogable
  21.     {
  22.         public void Write(string text)
  23.         {
  24.             Console.WriteLine(text);
  25.         }
  26.     }
  27.     interface ILogable
  28.     {
  29.         void Write(string text);
  30.     }
  31.  
  32.     class Log
  33.     {
  34.         private ILogable _form;
  35.  
  36.         private Log(ILogable form)
  37.         {
  38.             _form = form;
  39.         }
  40.  
  41.         public static Log CreateInstance(ILogable form)
  42.         {
  43.             return new Log(form);    
  44.         }
  45.  
  46.         public void Write(string text)
  47.         {
  48.             _form.Write(text);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement