Example #1
0
        private static PSDataCollection <T> CreateAndInitializeFromExplicitValue(object valueToConvert)
        {
            PSDataCollection <T> datas = new PSDataCollection <T> {
                LanguagePrimitives.ConvertTo <T>(valueToConvert)
            };

            datas.Complete();
            return(datas);
        }
Example #2
0
        /// <summary>
        /// Does the cleanup necessary on pipeline completion
        /// </summary>
        private void Cleanup()
        {
            //Close the output stream if it is not closed.
            if (_outputStream.IsOpen)
            {
                try
                {
                    _outputCollection.Complete();
                    _outputStream.Close();
                }
                catch (ObjectDisposedException)
                {
                }
            }

            //Close the error stream if it is not closed.
            if (_errorStream.IsOpen)
            {
                try
                {
                    _errorCollection.Complete();
                    _errorStream.Close();
                }
                catch (ObjectDisposedException)
                {
                }
            }

            //Close the input stream if it is not closed.
            if (_inputStream.IsOpen)
            {
                try
                {
                    _inputCollection.Complete();
                    _inputStream.Close();
                }
                catch (ObjectDisposedException)
                {
                }
            }

            try
            {
                //Runspace object maintains a list of pipelines in execution.
                //Remove this pipeline from the list. This method also calls the
                //pipeline finished event.
                ((RemoteRunspace)_runspace).RemoveFromRunningPipelineList(this);

                PipelineFinishedEvent.Set();
            }
            catch (ObjectDisposedException)
            {
            }
        }