Exemplo n.º 1
0
        /// <summary>
        /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile
        /// </summary>
        protected override void BeginProcessing()
        {
            FlushInitializationWarnings();
            SessionState = base.SessionState;
            var profile = _dataCollectionProfile;

            //TODO: Inject from CI server
            lock (lockObject)
            {
                if (_metricHelper == null)
                {
                    _metricHelper = new MetricHelper(profile);
                    _metricHelper.AddTelemetryClient(new TelemetryClient
                    {
                        InstrumentationKey = "7df6ff70-8353-4672-80d6-568517fed090"
                    });
                }
            }

            InitializeQosEvent();
            LogCmdletStartInvocationInfo();
            InitDebuggingFilter();
            SetupDebuggingTraces();
            SetupHttpClientPipeline();
            base.BeginProcessing();

            //Now see if the cmdlet has any Breaking change attributes on it and process them if it does
            //This will print any breaking change attribute messages that are applied to the cmdlet
            BreakingChangeAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteWarning);
            PreviewAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteDebug);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile
        /// </summary>
        protected override void BeginProcessing()
        {
            FlushInitializationWarnings();
            SessionState = base.SessionState;
            var profile = _dataCollectionProfile;

            //TODO: Inject from CI server
            if (_metricHelper == null)
            {
                lock (lockObject)
                {
                    if (_metricHelper == null)
                    {
                        _metricHelper = new MetricHelper(profile);
                        _metricHelper.AddDefaultTelemetryClient();
                    }
                }
            }

            // Fetch module name and version which will be used by telemetry and useragent
            if (this.MyInvocation != null && this.MyInvocation.MyCommand != null)
            {
                this.ModuleName = this.MyInvocation.MyCommand.ModuleName;
                if (this.MyInvocation.MyCommand.Version != null)
                {
                    this.ModuleVersion = this.MyInvocation.MyCommand.Version.ToString();
                }
            }
            else
            {
                this.ModuleName    = this.GetType().Assembly.GetName().Name;
                this.ModuleVersion = this.GetType().Assembly.GetName().Version.ToString();
            }

            InitializeQosEvent();
            LogCmdletStartInvocationInfo();
            InitDebuggingFilter();
            SetupDebuggingTraces();
            SetupHttpClientPipeline();
            base.BeginProcessing();

            //Now see if the cmdlet has any Breaking change attributes on it and process them if it does
            //This will print any breaking change attribute messages that are applied to the cmdlet
            BreakingChangeAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteWarning);
            PreviewAttributeHelper.ProcessCustomAttributesAtRuntime(this.GetType(), this.MyInvocation, WriteDebug);
        }