Beispiel #1
0
        public static double divide(this IAdvancedCalculator sc, int a, int b)
        {
            int result = b / a;

            sc.SetResult(result);
            return(result);
        }
        static void Main()
        {
            try
            {
                Pause();

                IApplicationContext ctx = ContextRegistry.GetContext();

                Console.WriteLine("Get Calculator...");
                IAdvancedCalculator firstCalc = (IAdvancedCalculator)ctx.GetObject("calculatorService");
                Console.WriteLine("Divide(11, 2) : " + firstCalc.Divide(11, 2));
                Console.WriteLine("Memory = " + firstCalc.GetMemory());
                firstCalc.MemoryAdd(2);
                Console.WriteLine("Memory + 2 = " + firstCalc.GetMemory());

                Console.WriteLine("Get Calculator...");
                IAdvancedCalculator secondCalc = (IAdvancedCalculator)ctx.GetObject("calculatorService");
                Console.WriteLine("Memory = " + secondCalc.GetMemory());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Pause();
            }
        }
 public SimpleCalculatorAdapter()
 {
     calc = new AdvancedCalculator();
 }