Documentation Coverage Report
Current view: top level - Cqrs/Configuration - ConfigurationExtensions.cs Hit Total Coverage
Version: 2.2 Artefacts: 3 3 100.0 %
Date: 2017-09-22

          Line data    Source code
       1             : using System;
       2             : using cdmdotnet.Logging;
       3             : using System.Reflection;
       4             : 
       5             : namespace Cqrs.Configuration
       6             : {
       7             :         /// <summary>
       8             :         /// A collection of extension methods for <see cref="IConfigurationManager"/>.
       9             :         /// </summary>
      10             :         public static class ConfigurationExtensions
      11           1 :         {
      12             :                 /// <summary>
      13             :                 /// Creates an instance of <see cref="ITelemetryHelper"/> if the value for <paramref name="configurationKey"/> is true.
      14             :                 /// </summary>
      15           1 :                 public static ITelemetryHelper CreateTelemetryHelper(this IConfigurationManager configurationManager, string configurationKey, IDependencyResolver dependencyResolver)
      16             :                 {
      17             :                         return CreateTelemetryHelper(configurationManager, configurationKey, dependencyResolver.Resolve<ICorrelationIdHelper>());
      18             :                 }
      19             : 
      20             :                 /// <summary>
      21             :                 /// Creates an instance of <see cref="ITelemetryHelper"/> if the value for <paramref name="configurationKey"/> is true.
      22             :                 /// </summary>
      23           1 :                 public static ITelemetryHelper CreateTelemetryHelper(this IConfigurationManager configurationManager, string configurationKey, ICorrelationIdHelper correlationIdHelper)
      24             :                 {
      25             :                         bool useApplicationInsightTelemetryHelper;
      26             :                         if (!bool.TryParse(configurationManager.GetSetting(configurationKey), out useApplicationInsightTelemetryHelper))
      27             :                                 useApplicationInsightTelemetryHelper = false;
      28             : 
      29             :                         if (useApplicationInsightTelemetryHelper)
      30             :                         {
      31             :                                 var helper = (ITelemetryHelper)Activator.CreateInstanceFrom(string.Format("{0}\\cdmdotnet.Logging.Azure.ApplicationInsights.dll", AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory), "cdmdotnet.Logging.Azure.ApplicationInsights.TelemetryHelper", false, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, null, new object[] { correlationIdHelper }, null, null).Unwrap();
      32             :                                 return helper;
      33             :                         }
      34             :                         return new NullTelemetryHelper();
      35             :                 }
      36             :         }
      37             : }

Generated by: LCOV version 1.10