Beispiel #1
0
 /// <summary>
 ///
 /// Simply accumulates the incoming objects
 ///
 /// </summary>
 protected override void ProcessRecord()
 {
     if (InputObject != null && InputObject != AutomationNull.Value)
     {
         InputObjects.Add(InputObject);
     }
 }
Beispiel #2
0
        protected override void EndProcessing()
        {
            InputObjects.Sort(Compare);

            IEnumerable <PSObject> outputObjects = InputObjects;

            if (Unique.ToBool())
            {
                PropertyEqualityComparer comparer = new PropertyEqualityComparer(null);
                if (Property != null)
                {
                    comparer.Properties = Property.Select(p => p.ToString()).ToList();
                }

                PSObject prevObj = null;
                foreach (PSObject obj in InputObjects)
                {
                    if (!comparer.Equals(obj, prevObj))
                    {
                        WriteObject(obj);
                    }
                    prevObj = obj;
                }
            }
            else
            {
                foreach (PSObject obj in InputObjects)
                {
                    WriteObject(obj);
                }
            }
        }
        public void PushObject(object instance)
        {
            lock (stackSyncObject) {
                InputObjects.Push(instance);
            }

            if (InputNotificationType == NotificationType.Auto)
            {
                OnInputAvailable();
            }
        }
        public void PushMultiObjects(IList <object> instances)
        {
            lock (stackSyncObject) {
                foreach (object instance in instances)
                {
                    InputObjects.Push(instance);
                }
            }

            if (InputNotificationType == NotificationType.Auto)
            {
                OnInputAvailable();
            }
        }
 public IEnumerable <object> ConsumeInput()
 {
     lock (stackSyncObject) {
         while (InputObjects.Count > 0)
         {
             object input = InputObjects.Pop();
             if (InputObjects.Count == 0)
             {
                 yield break;
             }
             else
             {
                 yield return(input);
             }
         }
     }
 }