<commit_before>﻿using System;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;

namespace Microsoft.Practices.EnterpriseLibrary.SemanticLogging.ApplicationInsights.Utility
{
    /// <summary>
    /// An <see cref="IContextInitializer"/> implementation that appends the <see cref="Environment.OSVersion"/> to an Application Insights <see cref="TelemetryContext"/>
    /// </summary>
    public class ApplicationVersionContextInitializer : IContextInitializer
    {
        /// <summary>
        /// Gets or sets the application version.
        /// </summary>
        /// <value>
        /// The application version.
        /// </value>
        private readonly string _applicationVersion;

        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationVersionContextInitializer"/> class.
        /// </summary>
        /// <param name="applicationVersion">The application version.</param>
        public ApplicationVersionContextInitializer(string applicationVersion)
        {
            if (applicationVersion == null) throw new ArgumentNullException("applicationVersion");

            _applicationVersion = applicationVersion;
        }

        #region Implementation of IContextInitializer

        /// <summary>
        /// Initializes the given <see cref="T:Microsoft.ApplicationInsights.DataContracts.TelemetryContext"/>.
        /// </summary>
        public void Initialize(TelemetryContext context)
        {
            if (context == null)
                return;

            if (string.IsNullOrWhiteSpace(context.Component.Version))
                context.Component.Version = _applicationVersion;
        }
<commit_msg>ApplicationVersionContextInitializer changed to use ITelemetryInitializer instead of IContextInitializer<commit_after>﻿using System;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;

namespace Microsoft.Practices.EnterpriseLibrary.SemanticLogging.ApplicationInsights.Utility
{
    /// <summary>
    /// An <see cref="ITelemetryInitializer"/> implementation that appends the applicationVersion to an Application Insights <see cref="ITelemetry.Context"/>
    /// </summary>
    public class ApplicationVersionContextInitializer : ITelemetryInitializer
    {
        /// <summary>
        /// Gets or sets the application version.
        /// </summary>
        /// <value>
        /// The application version.
        /// </value>
        private readonly string _applicationVersion;

        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationVersionContextInitializer"/> class.
        /// </summary>
        /// <param name="applicationVersion">The application version.</param>
        public ApplicationVersionContextInitializer(string applicationVersion)
        {
            if (applicationVersion == null) throw new ArgumentNullException("applicationVersion");

            _applicationVersion = applicationVersion;
        }

        #region Implementation of IContextInitializer

        /// <summary>
        /// Initializes the given <see cref="T:Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
        /// </summary>
        public void Initialize(Microsoft.ApplicationInsights.Channel.ITelemetry telemetry)
        {
            if (telemetry != null && telemetry.Context != null)
            {
                if (String.IsNullOrWhiteSpace(telemetry.Context.Component.Version))
                {
                    telemetry.Context.Component.Version = _applicationVersion;
                }
            }
        }
{'fraction_non_alphanumeric': 0.09925762991476492, 'fraction_numerical': 0.0, 'mean_word_length': 2.5631733594515183, 'pattern_counts': {'":': 0, '<': 36, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5935293', 'n_tokens_mistral': 831, 'n_tokens_neox': 817, 'n_words': 197}