Exemplo n.º 1
0
        /// <summary>
        /// Read a single object from the stream.
        /// </summary>
        /// <returns>
        /// The next object in the buffer or AutomationNull if buffer is closed
        /// and data is not available.
        /// </returns>
        /// <remarks>
        /// This method blocks if the buffer is empty.
        /// </remarks>
        public override ReturnType Read()
        {
            object result = AutomationNull.Value;
            if (_datastore.Count > 0)
            {
                Collection<DataStoreType> resultCollection = _datastore.ReadAndRemove(1);

                // ReadAndRemove returns a Collection<DataStoreType> type but we
                // just want the single object contained in the collection.
                if (resultCollection.Count == 1)
                {
                    result = resultCollection[0];
                }
            }

            return ConvertToReturnType(result);
        }
Exemplo n.º 2
0
        private T GetData <T>(PSDataCollection <T> collection, int index)
        {
            if (!this.flush)
            {
                return(collection[index]);
            }
            Collection <T> collection2 = collection.ReadAndRemove(1);

            if (collection2.Count > 0)
            {
                return(collection2[0]);
            }
            return(default(T));
        }