using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicGramms
{
	public delegate void Handler(string msg);

	internal class BasicEvent
	{
		//public event Handler EV; // event 키워드가 없는 경우, 클래스 외부에서 함수 직접 호출이 가능하게됨. (OOP 위반)
		public Handler EV;

		public void DoTest()
		{
			EV += WriteConosle;
			EV += WriteConosle;
			EV += WriteConosle;
			TestEvent("Test done");
		}
		
		public void TestEvent(string msg)
		{
			EV($"Event message: {msg}");
		}

		private void WriteConosle(string msg)
		{
			Console.WriteLine(msg);
		}
	}

	internal class BasicEventUser
	{
		private BasicEvent Basic = new BasicEvent();
		
		public BasicEventUser()
		{
			this.Basic.EV += WriteConsole;
			this.Basic.EV += WriteConsole;
			this.Basic.EV += WriteConsole;
		}

		public void DoTest()
		{
			Basic.EV("Test done");
		}
		
		private void WriteConsole(string msg)
		{
			Console.WriteLine($"ByUser: {msg}");
		}
		
	}
}
