このコードは、実行中にエラーや警告を出しません。しかし、それはconsole.read()関数を無視します、私はwindsorの方が新しいです。それは本当にバグなのか、それともウィンザーの単純な振る舞いなのか?
using System;
using Castle.Windsor;
using Castle.MicroKernel.Registration;
namespace CastleProject
{
class Program
{
internal interface ILogger
{
void log(string message);
void showMethod();
}
internal interface Ishowing
{
void checkInterface();
}
class Logger : ILogger
{
public void log(string message)
{
Console.WriteLine(message);
Console.Read();
}
public void showMethod()
{
Console.WriteLine("This is again showing just function i existing");
}
}
class Showing : Ishowing
{
public void checkInterface()
{
Console.WriteLine("this is line from checkInterface()");
var a = Console.ReadLine();
Console.WriteLine(a);
}
}
static void Main(string[] args)
{
var container = new WindsorContainer();
container.Register(Component.For<ILogger>().ImplementedBy<Logger>(),Component.For<Ishowing>().ImplementedBy<Showing>());
var logger = container.Resolve<ILogger>();
var logger2 = container.Resolve<Ishowing>();
logger.log("hello message");
logger.showMethod();
logger2.checkInterface();
}
}
}