< Summary

Class:SharpHoundCommonLib.CommonLib
Assembly:SharpHoundCommonLib
File(s):D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\CommonLib.cs
Covered lines:0
Uncovered lines:20
Coverable lines:20
Total lines:47
Line coverage:0% (0 of 20)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
InitializeCommonLib(...)0%800%
ReconfigureLogging(...)100%100%

File(s)

D:\a\SharpHoundCommon\SharpHoundCommon\src\CommonLib\CommonLib.cs

#LineLine coverage
 1using Microsoft.Extensions.Logging;
 2
 3namespace SharpHoundCommonLib
 4{
 5    public class CommonLib
 6    {
 7        private static bool _initialized;
 8
 9        /// <summary>
 10        ///     Initializes the common library with a log and cache instance.
 11        ///     If log/cache aren't provided, will use defaults
 12        /// </summary>
 13        /// <param name="log"></param>
 14        /// <param name="cache"></param>
 15        public static void InitializeCommonLib(ILogger log = null, Cache cache = null)
 016        {
 017            if (_initialized)
 018            {
 019                log?.LogWarning("Common Library is already initialized");
 020                return;
 21            }
 22
 023            _initialized = true;
 024            if (log != null)
 025                Logging.ConfigureLogging(log);
 26
 027            if (cache == null)
 028            {
 029                var newCache = Cache.CreateNewCache();
 030                Cache.SetCacheInstance(newCache);
 031            }
 32            else
 033            {
 034                Cache.SetCacheInstance(cache);
 035            }
 036        }
 37
 38        /// <summary>
 39        ///     Replaces the current logging instance with a new one
 40        /// </summary>
 41        /// <param name="log"></param>
 42        public static void ReconfigureLogging(ILogger log)
 043        {
 044            Logging.ConfigureLogging(log);
 045        }
 46    }
 47}