/// <summary>@ToDo: Complete documentation before stable release. {659}.</summary> /// <param name="source">@ToDo: Complete documentation before stable release. {688}.</param> /// <param name="target">@ToDo: Complete documentation before stable release. {859}.</param> public static void CopyTelemetryContext(TelemetryContext source, TelemetryContext target) { Util.ValidateNotNull(source, nameof(source)); Util.ValidateNotNull(target, nameof(target)); // Copy internal tags: target.Initialize(source, instrumentationKey: null); // Copy public properties: #pragma warning disable CS0618 // Type or member is obsolete Utils.CopyDictionary(source.Properties, target.Properties); #pragma warning restore CS0618 // Type or member is obsolete // This check avoids accessing the public accessor GlobalProperties // unless needed, to avoid the penalty of ConcurrentDictionary instantiation. if (source.GlobalPropertiesValue != null) { Utils.CopyDictionary(source.GlobalProperties, target.GlobalProperties); } // Copy iKey: if (source.InstrumentationKey != null) { target.InstrumentationKey = source.InstrumentationKey; } }
/// <summary>@ToDo: Complete documentation before stable release. {659}</summary> /// <param name="source">@ToDo: Complete documentation before stable release. {688}</param> /// <param name="target">@ToDo: Complete documentation before stable release. {859}</param> public static void CopyTelemetryContext(TelemetryContext source, TelemetryContext target) { Util.ValidateNotNull(source, nameof(source)); Util.ValidateNotNull(target, nameof(target)); // Copy internal tags: target.Initialize(source, instrumentationKey: null); // Copy public properties: IDictionary <string, string> sourceProperties = source.Properties; IDictionary <string, string> targetProperties = target.Properties; if (targetProperties != null && sourceProperties != null && sourceProperties.Count > 0) { foreach (KeyValuePair <string, string> property in sourceProperties) { if (false == String.IsNullOrEmpty(property.Key) && false == targetProperties.ContainsKey(property.Key)) { targetProperties[property.Key] = property.Value; } } } // Copy iKey: if (source.InstrumentationKey != null) { target.InstrumentationKey = source.InstrumentationKey; } }
/// <summary>@ToDo: Complete documentation before stable release. {659}</summary> /// <param name="source">@ToDo: Complete documentation before stable release. {688}</param> /// <param name="target">@ToDo: Complete documentation before stable release. {859}</param> public static void CopyTelemetryContext(TelemetryContext source, TelemetryContext target) { Util.ValidateNotNull(source, nameof(source)); Util.ValidateNotNull(target, nameof(target)); // Copy internal tags: target.Initialize(source, instrumentationKey: null); // Copy public properties: #pragma warning disable CS0618 // Type or member is obsolete Utils.CopyDictionary(source.Properties, target.Properties); #pragma warning restore CS0618 // Type or member is obsolete Utils.CopyDictionary(source.GlobalProperties, target.GlobalProperties); // Copy iKey: if (source.InstrumentationKey != null) { target.InstrumentationKey = source.InstrumentationKey; } }