private void DisableCmdletLog(object sender, EventArgs e)
 {
     if (this.context == null)
     {
         return;
     }
     if (ExchangePropertyContainer.IsCmdletLogEnabled(this.context.SessionState))
     {
         ExchangePropertyContainer.DisableCmdletLog(this.context.SessionState);
     }
 }
        public void Init(ITaskEvent task)
        {
            bool?flag = (bool?)this.context.InvocationInfo.Fields["CmdletLogEntriesEnabled"];

            if (flag != null && flag.Value)
            {
                ExchangePropertyContainer.EnableCmdletLog(this.context.SessionState);
            }
            if ((flag != null && flag.Value) || ExchangePropertyContainer.IsCmdletLogEnabled(this.context.SessionState))
            {
                task.PreInit += this.Task_PreInit;
                task.Stop    += this.DisableCmdletLog;
                task.Release += this.DisableCmdletLog;
                this.context.CommandShell.PrependTaskIOPipelineHandler(this);
            }
        }