/// <summary>
        /// Load an assembly from the specified location
        /// </summary>
        /// <param name="assemblyLocationInformation">AssemblyLocationInformation</param>
        /// <returns>Assembly</returns>
        public Assembly LoadAssembly(AssemblyLocationInformation assemblyLocationInformation)
        {
            // Check if the simple name can be found in the cache
            if (LoadedAssemblies.TryGetValue(assemblyLocationInformation.Name, out var assembly))
            {
                if (Log.IsInfoEnabled())
                {
                    Log.Info().WriteLine("Returned {0} from cache.", assemblyLocationInformation.Name);
                }
                return(assembly);
            }

            if (assemblyLocationInformation.IsEmbedded)
            {
                return(LoadEmbeddedAssembly(assemblyLocationInformation));
            }
            // Load from file
            return(LoadFromFile(assemblyLocationInformation));
        }
Beispiel #2
0
        /// <summary>
        ///     This will assert that the log levels work
        /// </summary>
        private static void AssertLogLevels(LogSource logSource, ILogger loggerUnderTest)
        {
            var initialLevel = loggerUnderTest.LogLevel;

            try
            {
                // Assert the log levels
                loggerUnderTest.LogLevel = LogLevels.None;
                Assert.False(logSource.IsVerboseEnabled());
                Assert.False(logSource.IsDebugEnabled());
                Assert.False(logSource.IsInfoEnabled());
                Assert.False(logSource.IsWarnEnabled());
                Assert.False(logSource.IsErrorEnabled());
                Assert.False(logSource.IsFatalEnabled());

                loggerUnderTest.LogLevel = LogLevels.Verbose;
                Assert.True(logSource.IsVerboseEnabled());
                Assert.True(logSource.IsDebugEnabled());
                Assert.True(logSource.IsInfoEnabled());
                Assert.True(logSource.IsWarnEnabled());
                Assert.True(logSource.IsErrorEnabled());
                Assert.True(logSource.IsFatalEnabled());

                loggerUnderTest.LogLevel = LogLevels.Debug;
                Assert.False(logSource.IsVerboseEnabled());
                Assert.True(logSource.IsDebugEnabled());
                Assert.True(logSource.IsInfoEnabled());
                Assert.True(logSource.IsWarnEnabled());
                Assert.True(logSource.IsErrorEnabled());
                Assert.True(logSource.IsFatalEnabled());

                loggerUnderTest.LogLevel = LogLevels.Info;
                Assert.False(logSource.IsVerboseEnabled());
                Assert.False(logSource.IsDebugEnabled());
                Assert.True(logSource.IsInfoEnabled());
                Assert.True(logSource.IsWarnEnabled());
                Assert.True(logSource.IsErrorEnabled());
                Assert.True(logSource.IsFatalEnabled());

                loggerUnderTest.LogLevel = LogLevels.Warn;
                Assert.False(logSource.IsVerboseEnabled());
                Assert.False(logSource.IsDebugEnabled());
                Assert.False(logSource.IsInfoEnabled());
                Assert.True(logSource.IsWarnEnabled());
                Assert.True(logSource.IsErrorEnabled());
                Assert.True(logSource.IsFatalEnabled());

                loggerUnderTest.LogLevel = LogLevels.Error;
                Assert.False(logSource.IsVerboseEnabled());
                Assert.False(logSource.IsDebugEnabled());
                Assert.False(logSource.IsInfoEnabled());
                Assert.False(logSource.IsWarnEnabled());
                Assert.True(logSource.IsErrorEnabled());
                Assert.True(logSource.IsFatalEnabled());

                loggerUnderTest.LogLevel = LogLevels.Fatal;
                Assert.False(logSource.IsVerboseEnabled());
                Assert.False(logSource.IsDebugEnabled());
                Assert.False(logSource.IsInfoEnabled());
                Assert.False(logSource.IsWarnEnabled());
                Assert.False(logSource.IsErrorEnabled());
                Assert.True(logSource.IsFatalEnabled());
            }
            finally
            {
                loggerUnderTest.LogLevel = initialLevel;
            }
        }