コード例 #1
0
 internal static bool TryCreateActionStage(string[] commandLine, out PipelineStage stage)
 {
     Type stageType;
     if (registeredActionStageTypes.TryGetValue(commandLine[0].ToLower(), out stageType) == false)
     {
         stage = null;
         return false;
     }
     else
     {
         stage = (PipelineStage)Activator.CreateInstance(stageType, new object[] { commandLine.Skip(1).ToArray() });
         return true;
     }
 }
コード例 #2
0
        internal void Push(object o, PipelineStage current)
        {
            if (Mode == PipelineMode.ParallelStages)
            {
                current.NextStage.Accept(o);
            }
            else if (Mode == PipelineMode.SerializedStages)
            {
                if (serializedStageInput.ContainsKey(current.NextStage) == false)
                {
                    serializedStageInput.Add(current.NextStage, new Queue <object>());
                }

                serializedStageInput[current.NextStage].Enqueue(o);
            }
            else
            {
                throw new NotSupportedException("Unknown mode: " + Mode);
            }
        }
コード例 #3
0
 /// <summary>
 /// Use this method to push an object to the given pipeline stage's next stage.  You should only use this
 /// for advanced scenarios where you're processing objects on a thread that was not created for you by
 /// PowerArgs.  If you're doing that and find the need to use this method, cool :).
 /// </summary>
 /// <param name="o">The object to push</param>
 /// <param name="current">The current pipeline stage.  The object is pushed to the next stage.</param>
 public static void Push(object o, PipelineStage current)
 {
     if (o == null)
     {
         if (ConsoleOutInterceptor.Instance.IsInitialized)
         {
             return;
         }
         ConsoleString.WriteLine("null object pushed through the pipeline", ConsoleColor.Yellow);
     }
     else if (current != null && current.NextStage != null && current.Manager != null)
     {
         current.Manager.Push(o, current);
     }
     else
     {
         ArgPipeline.FireObjectExited(o);
         if (ConsoleOutInterceptor.Instance.IsInitialized)
         {
             return;
         }
         PipelineOutputFormatter.Format(o).WriteLine();
     }
 }
コード例 #4
0
 internal static bool TryLoadOutputStage(string[] commandLine, out PipelineStage result)
 {
     return(TryLoadAddInObject <ExternalOutputPipelineStageProviderAttribute, PipelineStage>(out result, new object[] { commandLine }));
 }
コード例 #5
0
        internal void AddStage(PipelineStage toAdd)
        {
            if(_stages.Count > 0)
            {
                _stages.Last().NextStage = toAdd;
            }
            toAdd.Manager = this;
            toAdd.StageIndex = _stages.Count;

            toAdd.Drained += () =>
            {
                if(toAdd.NextStage != null)
                {
                    Queue<object> nextStageSerializedInput;
                    if(Mode == PipelineMode.SerializedStages && serializedStageInput.TryGetValue(toAdd.NextStage, out nextStageSerializedInput))
                    {
                        while(nextStageSerializedInput.Count > 0)
                        {
                            toAdd.NextStage.Accept(nextStageSerializedInput.Dequeue());
                        }
                    }

                    toAdd.NextStage.Drain();
                }
            };

            _stages.Add(toAdd);
        }
コード例 #6
0
        internal void Push(object o, PipelineStage current)
        {
            if (Mode == PipelineMode.ParallelStages)
            {
                current.NextStage.Accept(o);
            }
            else if (Mode == PipelineMode.SerializedStages)
            {
                if (serializedStageInput.ContainsKey(current.NextStage) == false)
                {
                    serializedStageInput.Add(current.NextStage, new Queue<object>());
                }

                serializedStageInput[current.NextStage].Enqueue(o);
            }
            else
            {
                throw new NotSupportedException("Unknown mode: " + Mode);
            }
        }
コード例 #7
0
ファイル: ArgPipeline.cs プロジェクト: abbottdev/PowerArgs
 /// <summary>
 /// Use this method to push an object to the given pipeline stage's next stage.  You should only use this
 /// for advanced scenarios where you're processing objects on a thread that was not created for you by
 /// PowerArgs.  If you're doing that and find the need to use this method, cool :).
 /// </summary>
 /// <param name="o">The object to push</param>
 /// <param name="current">The current pipeline stage.  The object is pushed to the next stage.</param>
 public static void Push(object o, PipelineStage current)
 {
     if (o == null)
     {
         if (ConsoleOutInterceptor.Instance.IsInitialized) return;
         ConsoleString.WriteLine("null object pushed through the pipeline", ConsoleColor.Yellow);
     }
     else if ( current != null && current.NextStage != null && current.Manager != null)
     {
         current.Manager.Push(o, current);
     }
     else
     {
         ArgPipeline.FireObjectExited(o);
         if (ConsoleOutInterceptor.Instance.IsInitialized) return;
         PipelineOutputFormatter.Format(o).WriteLine();
     }
 }