Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace throwaway
- {
- class Program
- {
- static void Main(string[] args)
- {
- Test t = new Test();
- Log l = Log.CreateInstance(t);
- l.Write("this is a test");
- Console.ReadLine();
- }
- }
- class Test : ILogable
- {
- public void Write(string text)
- {
- Console.WriteLine(text);
- }
- }
- interface ILogable
- {
- void Write(string text);
- }
- class Log
- {
- private ILogable _form;
- private Log(ILogable form)
- {
- _form = form;
- }
- public static Log CreateInstance(ILogable form)
- {
- return new Log(form);
- }
- public void Write(string text)
- {
- _form.Write(text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement