コード例 #1
0
ファイル: Program.cs プロジェクト: dmarin85/HW
        static void Main(string[] args)
        {
            HelloWorldWriterType helloWorldWriterType = (HelloWorldWriterType)Enum.Parse(typeof(HelloWorldWriterType), ConfigurationManager.AppSettings["WriterType"] ?? "0");

            IHelloWorldWriter writer = HelloWorldWriterFactory.GetInstance(helloWorldWriterType);

            writer.Write("Hello World");
            Environment.Exit(0);
        }
コード例 #2
0
        public static IHelloWorldWriter GetInstance(HelloWorldWriterType type)
        {
            switch (type)
            {
            case HelloWorldWriterType.Console:
                return(new ConsoleHelloWorldWriter());

            case HelloWorldWriterType.Database:
                return(new DataBaseHelloWorldWriter());

            default:
                throw new NotImplementedException();
            }
        }