コード例 #1
0
        /// <summary>
        /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile
        /// </summary>
        protected override void BeginProcessing()
        {
            InitializeProfile();
            PromptForDataCollectionProfileIfNotExists();
            InitializeQosEvent();
            if (string.IsNullOrEmpty(ParameterSetName))
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name));
            }
            else
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithParameterSetLog, this.GetType().Name, ParameterSetName));
            }

            if (Profile != null && Profile.Context != null && Profile.Context.Account != null && Profile.Context.Account.Id != null)
            {
                WriteDebugWithTimestamp(string.Format("using account id '{0}'...", Profile.Context.Account.Id));
            }

            _httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
            _adalListener           = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            base.BeginProcessing();
        }
コード例 #2
0
        /// <summary>
        /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile
        /// </summary>
        protected override void BeginProcessing()
        {
            PromptForDataCollectionProfileIfNotExists();
            InitializeQosEvent();
            if (string.IsNullOrEmpty(ParameterSetName))
            {
                WriteDebugWithTimestamp(string.Format("{0} begin processing without ParameterSet.", this.GetType().Name));
            }
            else
            {
                WriteDebugWithTimestamp(string.Format("{0} begin processing with ParameterSet '{1}'.", this.GetType().Name, ParameterSetName));
            }

            if (DefaultContext != null && DefaultContext.Account != null && DefaultContext.Account.Id != null)
            {
                WriteDebugWithTimestamp(string.Format("using account id '{0}'...", DefaultContext.Account.Id));
            }

            _httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
            _adalListener           = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue(
                ModuleName, string.Format("v{0}", ModuleVersion));

            AzureSession.ClientFactory.UserAgents.Add(userAgentValue);
            AzureSession.ClientFactory.AddHandler(new CmdletInfoHandler(this.CommandRuntime.ToString(), this.ParameterSetName));
            base.BeginProcessing();
        }
コード例 #3
0
 protected virtual void TearDownDebuggingTraces()
 {
     RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
     DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
     _azureEventListener?.Dispose();
     _azureEventListener = null;
     FlushDebugMessages();
 }
コード例 #4
0
 protected virtual void SetupDebuggingTraces()
 {
     _httpTracingInterceptor = _httpTracingInterceptor ?? new
                               RecordingTracingInterceptor(DebugMessages);
     _adalListener = _adalListener ?? new DebugStreamTraceListener(DebugMessages);
     RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
     DebugStreamTraceListener.AddAdalTracing(_adalListener);
 }
コード例 #5
0
        /// <summary>
        /// End processing. Flush messages in tracing interceptor and save profile.
        /// </summary>
        protected override void EndProcessing()
        {
            string message = string.Format(Resources.EndProcessingLog, this.GetType().Name);

            WriteDebugWithTimestamp(message);

            RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
            FlushMessagesFromTracingInterceptor();

            base.EndProcessing();
        }
コード例 #6
0
        /// <summary>
        /// End processing. Flush messages in tracing interceptor and save profile.
        /// </summary>
        protected override void EndProcessing()
        {
            LogQosEvent();
            string message = string.Format(Resources.EndProcessingLog, this.GetType().Name);

            WriteDebugWithTimestamp(message);

            RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
            DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
            FlushDebugMessages();

            base.EndProcessing();
        }
コード例 #7
0
        /// <summary>
        /// End processing. Flush messages in tracing interceptor and save profile and removes user agent.
        /// </summary>
        protected override void EndProcessing()
        {
            LogQosEvent();
            string message = string.Format("{0} end processing.", this.GetType().Name);

            WriteDebugWithTimestamp(message);

            RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
            DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
            FlushDebugMessages();

            AzureSession.ClientFactory.UserAgents.RemoveWhere(u => u.Product.Name == ModuleName);
            AzureSession.ClientFactory.RemoveHandler(typeof(CmdletInfoHandler));
            base.EndProcessing();
        }
コード例 #8
0
        protected virtual void SetupDebuggingTraces()
        {
            _httpTracingInterceptor = _httpTracingInterceptor ?? new
                                      RecordingTracingInterceptor(DebugMessages, _matchers);
            _adalListener = _adalListener ?? new DebugStreamTraceListener(DebugMessages);
            RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
            DebugStreamTraceListener.AddAdalTracing(_adalListener);

            if (AzureSession.Instance.TryGetComponent(nameof(IAzureEventListenerFactory), out IAzureEventListenerFactory factory))
            {
                _azureEventListener = factory.GetAzureEventListener(
                    (message) =>
                {
                    DebugMessages.Enqueue(message);
                });
            }
        }
コード例 #9
0
        /// <summary>
        /// Cmdlet begin process
        /// </summary>
        protected override void BeginProcessing()
        {
            if (string.IsNullOrEmpty(ParameterSetName))
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name));
            }
            else
            {
                WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithParameterSetLog, this.GetType().Name, ParameterSetName));
            }

            if (CurrentContext != null && CurrentContext.Account != null && CurrentContext.Account.Id != null)
            {
                WriteDebugWithTimestamp(string.Format("using account id '{0}'...", CurrentContext.Account.Id));
            }

            RecordingTracingInterceptor.AddToContext(httpTracingInterceptor);

            base.BeginProcessing();
        }