Beispiel #1
0
        /// <summary>
        /// Create handler for session state telemetry.
        /// </summary>
        private Action <ITelemetry> CreateHandlerForSessionStateTelemetry(EventSource eventSource, MethodInfo writeGenericMethod, Type eventSourceOptionsType, PropertyInfo eventSourceOptionsKeywordsProperty)
        {
            var eventSourceOptions = Activator.CreateInstance(eventSourceOptionsType);
            var keywords           = Keywords.SessionState;

            eventSourceOptionsKeywordsProperty.SetValue(eventSourceOptions, keywords);
            var dummySessionStateData = new SessionStateData();
            var writeMethod           = writeGenericMethod.MakeGenericMethod(new
            {
                PartA_iKey             = this.dummyPartAiKeyValue,
                PartA_Tags             = this.dummyPartATagsValue,
                PartB_SessionStateData = new
                {
                    // The properties and layout should be the same as SessionStateData_types.cs
                    dummySessionStateData.ver,
                    dummySessionStateData.state
                }
            }.GetType());

            return((item) =>
            {
                if (this.EventSourceInternal.IsEnabled(EventLevel.Verbose, keywords))
                {
                    var telemetryItem = item as SessionStateTelemetry;
                    var data = telemetryItem.Data;
                    var extendedData = new
                    {
                        // The properties and layout should be the same as the anonymous type in the above MakeGenericMethod
                        PartA_iKey = telemetryItem.Context.InstrumentationKey,
                        PartA_Tags = telemetryItem.Context.Tags,
                        PartB_SessionStateData = new
                        {
                            data.ver,
                            data.state
                        }
                    };

                    writeMethod.Invoke(eventSource, new object[] { SessionStateTelemetry.TelemetryName, eventSourceOptions, extendedData });
                }
            });
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionStateTelemetry"/> class.
 /// </summary>
 public SessionStateTelemetry()
 {
     this.Data    = new SessionStateData();
     this.context = new TelemetryContext();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionStateTelemetry"/> class.
 /// </summary>
 public SessionStateTelemetry()
 {
     this.Data    = new SessionStateData();
     this.context = new TelemetryContext(new Dictionary <string, string>(), new Dictionary <string, string>());
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SessionStateTelemetry"/> class.
 /// </summary>
 public SessionStateTelemetry()
 {
     this.Data = new SessionStateData();
     this.context = new TelemetryContext(new Dictionary<string, string>(), new Dictionary<string, string>());
 }