Exemple #1
0
        public async Task <ScanResult> ScanAsync(string filename)
        {
            FileInfo       fileInfo = new FileInfo(filename);
            LoggingSection log      = logging.CreateChild(fileInfo.Name);

            log.Verbose($"Starting {GetType().Name} on {fileInfo.FullName}");
            DateTime  timeStarted = DateTime.Now;
            string    result      = null;
            bool      succeeded;
            Exception exception = null;

            try
            {
                result = await DoScanAsync(fileInfo.FullName, log);

                succeeded = true;
                log.Verbose("Scan was successfull");
            }
            catch (Exception e)
            {
                succeeded = false;
                exception = e;
                log.Warning($"Scan failed: {e.Message}{Environment.NewLine}{e.StackTrace}");
            }
            DateTime timeEnded = DateTime.Now;

            log.Dispose();
            return(new ScanResult(result, fileInfo.FullName, this, timeStarted, timeEnded, succeeded, exception));
        }
        public void GetChildren_ShouldReturnNullAfterDisposal()
        {
            //Arrange
            LoggingSection loggingSection = new LoggingSection(this);

            //Act
            loggingSection.Dispose();

            //Assert
            Assert.Null(loggingSection.GetChildren());
        }
        public void Disposed_ShouldBeTrueAfterDisposal()
        {
            //Arrange
            LoggingSection loggingSection = new LoggingSection(this);

            //Act
            loggingSection.Dispose();

            //Assert
            Assert.True(loggingSection.Disposed);
        }
Exemple #4
0
        internal static void Dispose()
        {
            if (initiated)
            {
                logging.Info("Disposing Services");

                for (int i = servicesToBeDisposed.Count - 1; i >= 0; i--)
                {
                    Disable(servicesToBeDisposed[i]);
                }

                logging.Dispose();
                initiated = false;
            }
        }
Exemple #5
0
 public void Dispose()
 {
     logging.Dispose();
 }