public bool ShouldContinue(string query, string caption, ref bool yesToAll, ref bool noToAll, out bool?output)
        {
            bool result = true;

            output = null;
            using (List <ITaskIOPipeline> .Enumerator enumerator = this.pipelines.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ITaskIOPipeline pipeline = enumerator.Current;
                    string          text     = base.GetType().Name + ".ShouldContinue";
                    using (new CmdletMonitoredScope(this.context.UniqueId, "TaskModuleLatency", text, LoggerHelper.CmdletPerfMonitors))
                    {
                        ICriticalFeature feature = pipeline as ICriticalFeature;
                        bool             yesToAllFromDelegate = yesToAll;
                        bool             noToAllFromDelegate  = noToAll;
                        bool?            outputFromDelegate   = output;
                        feature.Execute(delegate
                        {
                            result = pipeline.ShouldContinue(query, caption, ref yesToAllFromDelegate, ref noToAllFromDelegate, out outputFromDelegate);
                        }, this.context, text);
                        yesToAll = yesToAllFromDelegate;
                        noToAll  = noToAllFromDelegate;
                        output   = outputFromDelegate;
                    }
                    if (!result)
                    {
                        break;
                    }
                }
            }
            return(result);
        }
 internal static void Execute(this ICriticalFeature feature, Action action, TaskContext taskContext, string methodNameInLog)
 {
     try
     {
         action();
     }
     catch (Exception ex)
     {
         Guid      uniqueId = taskContext.UniqueId;
         bool      flag     = false;
         Exception ex2;
         bool      needReportException = !TaskHelper.IsTaskKnownException(ex2) && TaskHelper.ShouldReportException(ex2, out flag);
         if (!needReportException)
         {
             CmdletLogger.SafeAppendGenericError(uniqueId, methodNameInLog, ex2.ToString(), false);
         }
         else
         {
             CmdletLogger.SafeAppendGenericError(uniqueId, methodNameInLog, ex2.ToString(), true);
             CmdletLogger.SafeSetLogger(uniqueId, RpsCmdletMetadata.ErrorType, "UnHandled");
         }
         if (feature == null || feature.IsCriticalException(ex2))
         {
             throw;
         }
         if (!flag)
         {
             taskContext.CommandShell.WriteWarning(Strings.WarningTaskModuleSkipped(methodNameInLog, ex2.Message));
         }
         Diagnostics.ReportException(ex2, Constants.CoreEventLogger, TaskEventLogConstants.Tuple_UnhandledException, (object ex) => needReportException, null, ExTraceGlobals.InstrumentationTracer, "Exception from  " + methodNameInLog + ": {0}");
     }
 }
Exemple #3
0
        private void ExecuteEventHandler <T>(T e, Delegate handler) where T : EventArgs
        {
            Type   declaringType = handler.Method.DeclaringType;
            string str           = (declaringType == null) ? "Global" : declaringType.Name;
            string name          = handler.Method.Name;
            string text          = str + "." + name;

            TaskLogger.Trace(Strings.LogFunctionEnter(declaringType, name, string.Join <ParameterInfo>(",", handler.Method.GetParameters())));
            using (new CmdletMonitoredScope(this.taskContext.UniqueId, "TaskModuleLatency", text, LoggerHelper.CmdletPerfMonitors))
            {
                ICriticalFeature feature = handler.Target as ICriticalFeature;
                feature.Execute(delegate
                {
                    ((EventHandler <T>)handler)(this, e);
                }, this.taskContext, text);
            }
            TaskLogger.Trace(Strings.LogFunctionExit(declaringType, name));
        }
        private bool ExecutePipeline <T>(TaskIOPipeline.PipelineExecuter <T> pipelineExecuter, string methodName, T input, out T output)
        {
            bool result = true;

            output = input;
            using (List <ITaskIOPipeline> .Enumerator enumerator = this.pipelines.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TaskIOPipeline.< > c__DisplayClass1a <T> CS$ < > 8__locals2 = new TaskIOPipeline.< > c__DisplayClass1a <T>();
                    CS$ < > 8__locals2.pipeline = enumerator.Current;
                    ICriticalFeature feature  = CS$ < > 8__locals2.pipeline as ICriticalFeature;
                    T      outputFromExecuter = input;
                    string text = base.GetType().Name + "." + methodName;
                    using (new CmdletMonitoredScope(this.context.UniqueId, "TaskModuleLatency", text, LoggerHelper.CmdletPerfMonitors))
                    {
                        feature.Execute(delegate
                        {
                            result = pipelineExecuter(CS$ < > 8__locals2.pipeline, input, out outputFromExecuter);
                        }, this.context, text);