Exemplo n.º 1
0
 /// <summary>
 /// Create TelemetrySessionContext with the name
 /// </summary>
 /// <param name="contextName"></param>
 /// <param name="theHostedSession">Session which owns this context</param>
 /// <param name="theScheduler"></param>
 /// <param name="theOverrideInit"></param>
 /// <param name="initializationAction"></param>
 internal TelemetryContext(string contextName, TelemetrySession theHostedSession, ITelemetryScheduler theScheduler = null, bool theOverrideInit = false, Action <TelemetryContext> initializationAction = null)
 {
     if (!IsContextNameValid(contextName))
     {
         throw new ArgumentException("contextName is invalid, contextName must contain alphanumeric characters only");
     }
     CodeContract.RequiresArgumentNotNull <TelemetrySession>(theHostedSession, "theHostedSession");
     if (theScheduler == null)
     {
         theScheduler = new TelemetryScheduler();
         theScheduler.InitializeTimed(TimeSpan.FromSeconds(15.0));
     }
     ContextName  = contextName;
     hostSession  = theHostedSession;
     scheduler    = theScheduler;
     overrideInit = theOverrideInit;
     hostSession.AddContext(this);
     initializationAction?.Invoke(this);
     if (!overrideInit)
     {
         hostSession.PostValidatedEvent(BuildStartEvent());
     }
 }