Exemplo n.º 1
0
        public bool PipelineContainsBlockingCmdletToNextPrtgCmdletOrEnd()
        {
            var commands = GetPipelineCommands();

            var myIndex = commands.IndexOf(cmdlet);

            for (var i = myIndex + 1; i < commands.Count; i++)
            {
                if (commands[i] is PrtgCmdlet)
                {
                    return(false);
                }

                if (SelectObjectDescriptor.IsSelectObjectCommand(commands[i]))
                {
                    var selectObject    = (PSCmdlet)commands[i];
                    var boundParameters = selectObject.MyInvocation.BoundParameters;

                    if (boundParameters.ContainsKey("Last"))
                    {
                        return(true);
                    }

                    if (boundParameters.ContainsKey("SkipLast"))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        public SelectObjectManager(ReflectionCacheManager manager, PSCmdlet cmdlet, Direction direction)
        {
            var cmds = manager.GetPipelineCommands();

            var myIndex = cmds.IndexOf(cmdlet);

            if (direction == Direction.Upstream)
            {
                for (int i = myIndex - 1; i >= 0; i--)
                {
                    if (SelectObjectDescriptor.IsSelectObjectCommand(cmds[i]))
                    {
                        Commands.Add(new SelectObjectDescriptor((PSCmdlet)cmds[i]));
                    }
                    else
                    {
                        if (i == myIndex - 1 && cmds[i] is WhereObjectCommand)
                        {
                            continue;
                        }

                        break;
                    }
                }
            }
            else
            {
                for (int i = myIndex + 1; i < cmds.Count; i++)
                {
                    if (SelectObjectDescriptor.IsSelectObjectCommand(cmds[i]))
                    {
                        Commands.Add(new SelectObjectDescriptor((PSCmdlet)cmds[i]));
                    }
                    else
                    {
                        if (i == myIndex + 1 && cmds[i] is WhereObjectCommand)
                        {
                            continue;
                        }

                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public PrtgOperationCmdlet TryGetFirstOperationCmdletAfterSelectObject()
        {
            var commands = GetPipelineCommands();

            var myIndex = commands.IndexOf(cmdlet);

            for (int i = myIndex; i >= 1; i--)
            {
                if (SelectObjectDescriptor.IsSelectObjectCommand(commands[i - 1]))
                {
                    if (commands[i] is PrtgOperationCmdlet)
                    {
                        return(commands[i] as PrtgOperationCmdlet);
                    }

                    return(null);
                }
            }

            return(null);
        }
Exemplo n.º 4
0
        private bool IndexNeedsCompleting(SelectObjectDescriptor firstCmdlet, ProgressManager manager)
        {
            if (manager.LastPrtgCmdletInPipeline)
            {
                if (manager.PipeFromVariableWithProgress)
                {
                    if (manager.EntirePipeline.CurrentIndex + 1 == firstCmdlet.Index.Last() + 1)
                    {
                        return(true);
                    }
                }
                else
                {
                    if (manager.RecordsProcessed == firstCmdlet.Index.Last() + 1)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }