Пример #1
0
        /// <summary>
        /// Create new default session with specified parameters
        /// </summary>
        /// <param name="appInsightsIKey"></param>
        /// <param name="asimovIKey"></param>
        /// <returns></returns>
        public static TelemetrySession CreateAndGetDefaultSession(string appInsightsIKey, string asimovIKey)
        {
            bool flag = true;

            if (InternalDefaultSession == null)
            {
                lock (lockDefaultSessionCreation)
                {
                    if (InternalDefaultSession == null)
                    {
                        CodeContract.RequiresArgumentNotEmptyOrWhitespace(appInsightsIKey, "appInsightsIKey");
                        CodeContract.RequiresArgumentNotEmptyOrWhitespace(asimovIKey, "asimovIKey");
                        TelemetrySessionInitializer @default = TelemetrySessionInitializer.Default;
                        @default.AppInsightsInstrumentationKey = appInsightsIKey;
                        @default.AsimovInstrumentationKey      = asimovIKey;
                        InternalDefaultSession = TelemetrySession.Create(@default);
                        flag = false;
                    }
                }
            }
            if (flag)
            {
                throw new InvalidOperationException("Unable to create new default Telemetry Session with provided keys.");
            }
            return(InternalDefaultSession);
        }
Пример #2
0
 /// <summary>
 /// Validate initializer for the TelemetrySession
 /// </summary>
 public void Validate()
 {
     CodeContract.RequiresArgumentNotEmptyOrWhitespace(AppInsightsInstrumentationKey, "AppInsightsInstrumentationKey");
     CodeContract.RequiresArgumentNotEmptyOrWhitespace(AsimovInstrumentationKey, "AsimovInstrumentationKey");
     CodeContract.RequiresArgumentNotNull <IDiagnosticTelemetry>(DiagnosticTelemetry, "DiagnosticTelemetry");
     CodeContract.RequiresArgumentNotNull <IHostInformationProvider>(HostInformationProvider, "HostInformationProvider");
     CodeContract.RequiresArgumentNotNull <IMachineInformationProvider>(MachineInformationProvider, "MachineInformationProvider");
     CodeContract.RequiresArgumentNotNull <IUserInformationProvider>(UserInformationProvider, "UserInformationProvider");
     CodeContract.RequiresArgumentNotNull <ITelemetryScheduler>(EventProcessorScheduler, "EventProcessorScheduler");
     CodeContract.RequiresArgumentNotNull <IContextPropertyManager>(DefaultContextPropertyManager, "DefaultContextPropertyManager");
     CodeContract.RequiresArgumentNotNull <IEnumerable <IChannelValidator> >(ChannelValidators, "ChannelValidators");
     CodeContract.RequiresArgumentNotNull <ITelemetryOptinStatusReader>(OptinStatusReader, "OptinStatusReader");
 }