Ejemplo n.º 1
0
 protected override void ProcessRecord()
 {
     MshCommandRuntime commandRuntime = base.CommandRuntime as MshCommandRuntime;
     if (commandRuntime != null)
     {
         VerboseRecord record = new VerboseRecord(this.Message);
         InvocationInfo variableValue = base.GetVariableValue("MyInvocation") as InvocationInfo;
         if (variableValue != null)
         {
             record.SetInvocationInfo(variableValue);
         }
         commandRuntime.WriteVerbose(record, false);
     }
     else
     {
         base.WriteVerbose(this.Message);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Display verbose information
        /// </summary>
        internal void WriteVerbose(VerboseRecord record, bool overrideInquire = false)
        {
            ActionPreference preference = VerbosePreference;
            if (overrideInquire && preference == ActionPreference.Inquire)
                preference = ActionPreference.Continue;

            if (WriteHelper_ShouldWrite(preference, lastVerboseContinueStatus))
            {
                if (record.InvocationInfo == null)
                {
                    record.SetInvocationInfo(MyInvocation);
                }

                if (VerboseOutputPipe != null)
                {
                    if (CBhost != null && CBhost.InternalUI != null &&
                        VerboseOutputPipe.NullPipe)
                    {
                        // If redirecting to a null pipe, still write to
                        // information buffers.
                        CBhost.InternalUI.WriteVerboseInfoBuffers(record);
                    }

                    // Add note property so that the verbose output is formatted correctly.
                    PSObject verboseWrap = PSObject.AsPSObject(record);
                    if (verboseWrap.Members["WriteVerboseStream"] == null)
                    {
                        verboseWrap.Properties.Add(new PSNoteProperty("WriteVerboseStream", true));
                    }

                    VerboseOutputPipe.Add(verboseWrap);
                }
                else
                {
                    //
                    // If no pipe, write directly to host.
                    //
                    if (null == Host || null == Host.UI)
                    {
                        Diagnostics.Assert(false, "No host in CommandBase.WriteVerbose()");
                        throw PSTraceSource.NewInvalidOperationException();
                    }

                    CBhost.InternalUI.TranscribeResult(StringUtil.Format(InternalHostUserInterfaceStrings.VerboseFormatString, record.Message));
                    CBhost.InternalUI.WriteVerboseRecord(record);
                }
            }

            lastVerboseContinueStatus = WriteHelper(
                null,
                null,
                preference,
                lastVerboseContinueStatus,
                "VerbosePreference",
                record.Message);
        }
Ejemplo n.º 3
0
 internal void WriteVerbose(VerboseRecord record, bool overrideInquire = false)
 {
     ActionPreference verbosePreference = this.VerbosePreference;
     if (overrideInquire && (verbosePreference == ActionPreference.Inquire))
     {
         verbosePreference = ActionPreference.Continue;
     }
     if (this.WriteHelper_ShouldWrite(verbosePreference, this.lastVerboseContinueStatus))
     {
         if (record.InvocationInfo == null)
         {
             record.SetInvocationInfo(this.MyInvocation);
         }
         if (this.VerboseOutputPipe != null)
         {
             if (((this.CBhost != null) && (this.CBhost.InternalUI != null)) && this.VerboseOutputPipe.NullPipe)
             {
                 this.CBhost.InternalUI.WriteVerboseInfoBuffers(record);
             }
             PSObject obj2 = PSObject.AsPSObject(record);
             if (obj2.Members["WriteVerboseStream"] == null)
             {
                 obj2.Properties.Add(new PSNoteProperty("WriteVerboseStream", true));
             }
             this.VerboseOutputPipe.Add(obj2);
         }
         else
         {
             if ((this.Host == null) || (this.Host.UI == null))
             {
                 throw PSTraceSource.NewInvalidOperationException();
             }
             this.CBhost.InternalUI.WriteVerboseRecord(record);
         }
     }
     this.lastVerboseContinueStatus = this.WriteHelper(null, null, verbosePreference, this.lastVerboseContinueStatus, "VerbosePreference", record.Message);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// This method implements the ProcessRecord method for Write-verbose command
        /// </summary>
        protected override void ProcessRecord()
        {
            //
            // The write-verbose command must use the script's InvocationInfo rather than its own,
            // so we create the VerboseRecord here and fill it up with the appropriate InvocationInfo;
            // then, we call the command runtime directly and pass this record to WriteVerbose().
            //
            MshCommandRuntime mshCommandRuntime = this.CommandRuntime as MshCommandRuntime;

            if (mshCommandRuntime != null)
            {
                VerboseRecord record = new VerboseRecord(Message);

                InvocationInfo invocationInfo = GetVariableValue(SpecialVariables.MyInvocation) as InvocationInfo;

                if (invocationInfo != null)
                {
                    record.SetInvocationInfo(invocationInfo);
                }

                mshCommandRuntime.WriteVerbose(record);
            }
            else
            {
                WriteVerbose(Message);
            }
        }//processrecord