Example #1
0
        public override bool DoOperation(IEnumerable <KeyValuePair <string, string> > kvPairs)
        {
            Console.WriteLine("Doing some stuff in the Metrics Decorator");
            var timer = new Stopwatch();

            timer.Start();

            var result = Operable.DoOperation(kvPairs);

            timer.Stop();
            Console.WriteLine($"It took {timer.ElapsedMilliseconds} milliseconds to do the operation.");
            return(result);
        }
 public override bool DoOperation(IEnumerable <KeyValuePair <string, string> > kvPairs)
 {
     try
     {
         Console.WriteLine("Doing some action before the operation inside of the ErrorHandlingDecorator");
         var result = Operable.DoOperation(kvPairs);
         Console.WriteLine("Doing some action after the operation inside of the ErrorHandlingDecorator");
         return(result);
     }
     catch (Exception e)
     {
         Console.WriteLine("Uh oh, something went wrong. Handling errors");
         throw;
     }
 }