Beispiel #1
0
        public int Execute(IMetaGenerator metaTypeGenerator, InvocationContext context)
        {
            var result = ExitCode.Success;

            _assemblyProvider.PluginAssembly = metaTypeGenerator.GetType().Assembly;

            try
            {
                _timeKeeper.MeasureTime(metaTypeGenerator.Register, "Registration");

                if (VerifyTools())
                {
                    _userInputProvider.AskUser(UserArguments(context));

                    _timeKeeper.MeasureTime(metaTypeGenerator.Prepare, "Prepartion");
                    _timeKeeper.MeasureTime(metaTypeGenerator.Generate, "Generation");
                    _timeKeeper.MeasureTime(metaTypeGenerator.TearDown, "Tear down");
                }
                else
                {
                    result = ExitCode.ToolMissing;
                }

                _timeKeeper.Print();
            }
            catch (Exception exception)
            {
                _exceptionFormatter.FormatException(exception);
                result = ExitCode.ExceptionOccured;
            }

            return(result);
        }
        /// <summary>
        /// Log Exceptions.
        /// </summary>
        /// <param name="exceptions">Exception to be logged.</param>
        /// <returns>Operation result detailing whether log was successful.</returns>
        public OperationResult LogExceptions(params Exception[] exceptions)
        {
            var operation = Get.OperationResult(() => _logger.Log(_formatter.FormatException(exceptions)));

            ErrorLogged?.Invoke(this, new GenericEventArgs <bool>(operation.WasSuccessful));
            return(operation);
        }
Beispiel #3
0
 /// <summary>
 /// Log Exceptions Asynchronously.
 /// </summary>
 /// <param name="exceptions">Exception to be logged.</param>
 /// <returns>Operation result detailing whether log was successful.</returns>
 public async Task <OperationResult> LogExceptionsAsync(params Exception[] exceptions) =>
 await Get.OperationResultAsync(() => _logger.Log(_formatter.FormatException(exceptions)));