示例#1
0
文件: Pipe.cs 项目: zuisom/PowerShell
 /// <summary>
 /// Removes all the objects from the Pipe.
 /// </summary>
 internal void Clear()
 {
     if (ObjectQueue != null)
     {
         ObjectQueue.Clear();
     }
 }
示例#2
0
文件: Pipe.cs 项目: zuisom/PowerShell
        private void AddToPipe(object obj)
        {
            if (PipelineProcessor != null)
            {
                // Put the pipeline on the notification stack for stop.
                _context.PushPipelineProcessor(PipelineProcessor);
                PipelineProcessor.Step(obj);
                _context.PopPipelineProcessor(false);
            }
            else if (_resultCollection != null)
            {
                _resultCollection.Add(obj != null ? PSObject.AsPSObject(obj) : null);
            }
            else if (_resultList != null)
            {
                _resultList.Add(obj);
            }
            else if (_externalWriter != null)
            {
                _externalWriter.Write(obj);
            }
            else if (ObjectQueue != null)
            {
                ObjectQueue.Enqueue(obj);

                // This is the "streamlet" recursive call
                if (_downstreamCmdlet != null && ObjectQueue.Count > OutBufferCount)
                {
                    _downstreamCmdlet.DoExecute();
                }
            }
        }
        protected virtual void DequeueCrossOrder(SpriteRenderer SR)
        {
            int MoveDir = 0;

            switch (MoveDirection)
            {
            case EDirection.LEFT:
                if (SR.transform.position.x <= LeftBorderX)
                {
                    MoveDir = -1;
                }
                break;

            case EDirection.RIGHT:
                if (SR.transform.position.x >= RightBorderX)
                {
                    MoveDir = 1;
                }
                break;
            }
            float SpriteWidth = SR.sprite.bounds.size.x;

            SpriteWidth *= SR.transform.localScale.x;
            Vector3 PosDelta = new Vector3(1, 0, 0) * SpriteWidth * (ObjectQueue.Count) * (-MoveDir);

            SR.transform.position += PosDelta;
            ObjectQueue.Dequeue();
            ObjectQueue.Enqueue(SR);
        }
        protected override void CheckQueue()
        {
            if (ObjectQueue.Count != 0)
            {
                SpriteRenderer SR             = ObjectQueue.Peek();
                bool           HasCrossBorder = false;
                switch (MoveDirection)
                {
                case EDirection.LEFT:
                    if (SR.transform.position.x <= LeftBorderX)
                    {
                        HasCrossBorder = true;
                    }
                    break;

                case EDirection.RIGHT:
                    if (SR.transform.position.x >= RightBorderX)
                    {
                        HasCrossBorder = true;
                    }
                    break;
                }
                if (HasCrossBorder)
                {
                    DequeueCrossOrder(SR);
                }
            }
        }
示例#5
0
 /// <summary>
 /// 销毁所有池内对象;
 /// </summary>
 public void DestroyAll()
 {
     foreach (var item in ObjectQueue)
     {
         Destroy(item);
     }
     ObjectQueue.Clear();
 }
示例#6
0
 public static void OpenQueue(TestContext testContext)
 {
     queue = new ObjectQueue(
         ConfigurationManager.AppSettings["AWSAccessKey"],
         ConfigurationManager.AppSettings["AWSSecretKey"],
         "AmazonSqs-ObjectQueue-UnitTests"
         );
 }
示例#7
0
 public static void OpenQueue(TestContext testContext)
 {
     queue = new ObjectQueue(
         ConfigurationManager.AppSettings["AWSAccessKey"],
         ConfigurationManager.AppSettings["AWSSecretKey"],
         "AmazonSqs-ObjectQueue-UnitTests"
     );
 }
示例#8
0
文件: Pipe.cs 项目: zuisom/PowerShell
        /// <summary>
        /// Returns the currently queued items in the pipe.  Note that this will
        /// not block on ExternalInput, and it does not modify the contents of
        /// the pipe.
        /// </summary>
        /// <returns>Possibly empty array of objects, but not null.</returns>
        internal object[] ToArray()
        {
            if (ObjectQueue == null || ObjectQueue.Count == 0)
            {
                return(MshCommandRuntime.StaticEmptyArray);
            }

            return(ObjectQueue.ToArray());
        }
示例#9
0
 /// <summary>
 /// 设置到最大容量;
 /// </summary>
 public void SetMaxCapacity(int maxCapacity)
 {
     MaxCapacity = maxCapacity;
     while (IsFull)
     {
         T item = ObjectQueue.Dequeue();
         Destroy(item);
     }
 }
示例#10
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
示例#11
0
文件: Pipe.cs 项目: zuisom/PowerShell
        /// <summary>
        /// Returns an object from the pipe. If pipe is empty returns null.
        /// This will try the ExternalReader if there are no queued objects.
        /// </summary>
        /// <returns>
        /// object that is retrieved, or AutomationNull.Value if none
        /// </returns>
        internal object Retrieve()
        {
            if (ObjectQueue != null && ObjectQueue.Count != 0)
            {
                return(ObjectQueue.Dequeue());
            }
            else if (_enumeratorToProcess != null)
            {
                if (_enumeratorToProcessIsEmpty)
                {
                    return(AutomationNull.Value);
                }

                if (!ParserOps.MoveNext(_context, null, _enumeratorToProcess))
                {
                    _enumeratorToProcessIsEmpty = true;
                    return(AutomationNull.Value);
                }

                return(ParserOps.Current(null, _enumeratorToProcess));
            }
            else if (ExternalReader != null)
            {
                try
                {
                    object o = ExternalReader.Read();
                    if (AutomationNull.Value == o)
                    {
                        // NOTICE-2004/06/08-JonN 963367
                        // The fix to this bug involves making one last
                        // attempt to read from the pipeline in DoComplete.
                        // We should be sure to not hit the ExternalReader
                        // again if it already reported completion.
                        ExternalReader = null;
                    }

                    return(o);
                }
                catch (PipelineClosedException)
                {
                    return(AutomationNull.Value);
                }
                catch (ObjectDisposedException)
                {
                    return(AutomationNull.Value);
                }
            }
            else
            {
                return(AutomationNull.Value);
            }
        }
示例#12
0
 /// <summary>
 /// 获取到对象实例;
 /// </summary>
 public T Get()
 {
     if (IsEmpty)
     {
         T item = Instantiate();
         return(item);
     }
     else
     {
         T item = ObjectQueue.Dequeue();
         ResetWhenOutPool(item);
         return(item);
     }
 }
示例#13
0
        /// <summary>
        /// 将对象放入池中,并且重置其数据;
        /// </summary>
        public void Release(T item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            if (IsFull)
            {
                Destroy(item);
            }
            else
            {
                ResetWhenEnterPool(item);
                ObjectQueue.Enqueue(item);
            }
        }