Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new[] { "10", "+", "20", "+", "30" };
            }

            using (var container = new UnityContainer())
            {
                Bootstrapper.SetupContainer(container);

                var calculator = container.Resolve<ICalculator>();
                int result = calculator.Evaluate(args);

                // TODO: Fix the NullReferenceException issue
                IConsoleAndFileResultWriter resultWriter = new ConsoleAndFileResultWriter("output.txt");
                resultWriter = container.BuildUp(resultWriter);

                resultWriter.WriteResult(result);
            }
        }
Ejemplo n.º 2
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new[] { "10", "+", "20", "+", "30" };
            }

            using (var container = new UnityContainer())
            {
                Bootstrapper.SetupContainer(container);

                var calculator = container.Resolve <ICalculator>();
                int result     = calculator.Evaluate(args);

                // TODO: Fix the NullReferenceException issue
                IConsoleAndFileResultWriter resultWriter = new ConsoleAndFileResultWriter("output.txt");
                resultWriter = container.BuildUp(resultWriter);

                resultWriter.WriteResult(result);
            }
        }
Ejemplo n.º 3
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new[] { "10", "+", "20", "+", "30" };
            }

            using (var container = new UnityContainer())
            {
                Bootstrapper.SetupContainer(container);

                var calculator = container.Resolve<ICalculator>();
                int result = calculator.Evaluate(args);

                // This is the second possible solution - use a concrete type for variable passed to BuildUp method
                ConsoleAndFileResultWriter resultWriter = new ConsoleAndFileResultWriter("output.txt");
                resultWriter = container.BuildUp(resultWriter);

                resultWriter.WriteResult(result);
            }
        }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new[] { "10", "+", "20", "+", "30" };
            }

            using (var container = new UnityContainer())
            {
                Bootstrapper.SetupContainer(container);

                var calculator = container.Resolve <ICalculator>();
                int result     = calculator.Evaluate(args);

                // This is the second possible solution - use a concrete type for variable passed to BuildUp method
                ConsoleAndFileResultWriter resultWriter = new ConsoleAndFileResultWriter("output.txt");
                resultWriter = container.BuildUp(resultWriter);

                resultWriter.WriteResult(result);
            }
        }