/// <summary>
        /// Initialise the ExceptionReporter
        /// </summary>
        public ExceptionReporter()
        {
            var callingAssembly = Assembly.GetCallingAssembly();

            _reportInfo = new ExceptionReportInfo {
                AppAssembly = callingAssembly
            };
        }
Example #2
0
 /// <summary>
 /// Initialise the ExceptionReporter
 /// </summary>
 public ExceptionReporter()
 {
     _reportInfo = new ExceptionReportInfo
     {
         AppAssembly = Assembly.GetCallingAssembly()
     };
     ViewMaker = new ViewMaker(_reportInfo);
 }
Example #3
0
        public static T Create <T>(ViewResolver viewResolver, ExceptionReportInfo reportInfo) where T : class
        {
            var view = viewResolver.Resolve <T>();

            var constructor = view.GetConstructor(new[] { typeof(ExceptionReportInfo) });
            var newInstance = constructor.Invoke(new object[] { reportInfo });

            return(newInstance as T);
        }
        /// <summary>
        /// Initialise the ExceptionReporter
        /// <remarks>readConfig() should be called (explicitly) if you need to override default config settings</remarks>
        /// </summary>
        public ExceptionReporter()
        {
            var callingAssembly = Assembly.GetCallingAssembly();

            _reportInfo = new ExceptionReportInfo
            {
                AppAssembly = callingAssembly
            };

            _viewResolver          = new ViewResolver(callingAssembly);
            _internalExceptionView = ViewFactory.Create <IInternalExceptionView>(_viewResolver);
        }
Example #5
0
        /// <summary>
        /// Initialises some ExceptionReportInfo properties related to the application/system
        /// </summary>
        /// <param name="reportInfo">an ExceptionReportInfo, can be pre-populated with config
        /// however 'base' properties such as MachineName</param>
        public ReportGenerator(ExceptionReportInfo reportInfo)
        {
            // this is going to be a dev/learning mistake - fail fast and hard
            _info = reportInfo ?? throw new ArgumentNullException(nameof(reportInfo));
            if (_info.AppAssembly == null)
            {
                _info.AppAssembly = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly();
            }

            _info.AppName       = _info.AppName.IsEmpty() ? _info.AppAssembly.GetName().Name: _info.AppName;
            _info.AppVersion    = _info.AppVersion.IsEmpty() ? GetAppVersion() : _info.AppVersion;
            _info.ExceptionDate = _info.ExceptionDateKind != DateTimeKind.Local ? DateTime.UtcNow : DateTime.Now;
        }
        /// <summary>
        /// Initialises some ExceptionReportInfo properties related to the application/system
        /// </summary>
        /// <param name="reportInfo">an ExceptionReportInfo, can be pre-populated with config
        /// however 'base' properties such as MachineName</param>
        public ExceptionReportGenerator(ExceptionReportInfo reportInfo)
        {
            _reportInfo = reportInfo ?? throw new ExceptionReportGeneratorException("reportInfo cannot be null");

            _reportInfo.ExceptionDate = _reportInfo.ExceptionDateKind != DateTimeKind.Local ? DateTime.UtcNow : DateTime.Now;
            _reportInfo.RegionInfo    = Application.CurrentCulture.DisplayName;

            _reportInfo.AppName    = string.IsNullOrEmpty(_reportInfo.AppName) ? Application.ProductName : _reportInfo.AppName;
            _reportInfo.AppVersion = string.IsNullOrEmpty(_reportInfo.AppVersion) ? GetAppVersion() : _reportInfo.AppVersion;
            if (_reportInfo.AppAssembly == null)
            {
                _reportInfo.AppAssembly = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly();
            }
        }
 /// <summary>
 /// Construct an ExceptionReport from a StringBuilder
 /// </summary>
 public ExceptionReport(StringBuilder stringBuilder, ExceptionReportInfo reportInfo, IList <SysInfoResult> sysInfoResults)
 {
     _reportString   = stringBuilder;
     _reportInfo     = reportInfo;
     _sysInfoResults = sysInfoResults;
 }
Example #8
0
 /// <summary>
 /// constructor
 /// </summary>
 public ExceptionReportPresenter(IExceptionReportView view, ExceptionReportInfo info)
 {
     _view            = view;
     ReportInfo       = info;
     _reportGenerator = new ExceptionReportGenerator(ReportInfo);
 }
 /// <summary>
 /// Initialise the ExceptionReporter
 /// </summary>
 public ExceptionReporter()
 {
     _info     = new ExceptionReportInfo();
     ViewMaker = new ViewMaker(_info);
 }
Example #10
0
 /// <summary>
 /// Initialise the ExceptionReporter
 /// </summary>
 protected ExceptionReporterBase()
 {
     _info = new ExceptionReportInfo();
 }