Пример #1
0
        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);
        }
Пример #2
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));
        }