 public HpcCommandsInfo(string keyword)
            : this(keyword, null, JobConfigurationUtilities.GetFileStream(JobConfigurationUtilities.ConfigurationFileName))
        { }

        public HpcCommandsInfo(string keyword, string workingDirectory)
            : this(keyword, workingDirectory, JobConfigurationUtilities.GetFileStream(JobConfigurationUtilities.ConfigurationFileName))
        { }

        public HpcCommandsInfo(string keyword, string workingDirectory, Stream jobConfigFile)
        {
            if (jobConfigFile == null)
                throw new ArgumentNullException("jobConfigFile");

            if (string.IsNullOrEmpty(keyword))
                throw new ArgumentNullException("keyword");

            this._jobConfigFile = jobConfigFile;
            this._keyword = keyword;
            this._workingDirectory = workingDirectory;
        }

        /// <summary>
        /// This Constructor should only be used for testing...
        /// </summary>
        public HpcCommandsInfo(Stream hpcCommandsStream, Stream protocolStream)
        {
            if (hpcCommandsStream == null)
                throw new ArgumentNullException("hpcCommandsStream");

            this._hpcCommandsStream = hpcCommandsStream;
            this._protocolStream = protocolStream;

            this._hpcCommandsFiles = new List<string>();
            this._protocolFiles = new List<string>();
        }

        #endregion

        #region Properties

        /// <summary>
        /// A Stream of the merged HpcCommands File created from the HpcCommandsFiles
        /// </summary>
        public Stream HpcCommandStream
        {
            get
            {
                if (_hpcCommandsStream == null)
                    _hpcCommandsStream = JobConfigurationUtilities.CreateStreamOfCombinedXmlFiles(_workingDirectory, HpcCommandsFiles, false, true);

                return _hpcCommandsStream;
            }
        }

        /// <summary>
        /// A Stream of the merged Protocol File created from the ProtocolFiles.  Check IsProtocolStreamUsed before Accessing.
        /// </summary>
        public Stream ProtocolStream
        {
            get
            {
                if (!IsProtocolUsed)
                    throw new InvalidOperationException("Protocol Stream called when Protocol is not used");

                if (_protocolStream == null)
                    _protocolStream = JobConfigurationUtilities.CreateStreamOfCombinedXmlFiles(_workingDirectory, ProtocolFiles, false, true);

                return _protocolStream;
            }
        }

        /// <summary>
        /// Determines if the Protocol Stream is valid by checking to see if there are any Files.
        /// </summary>
        public bool IsProtocolUsed
        {
            get 
            {
                return ProtocolFiles.Any();
            }
        }

        /// <summary>
        /// A List of the Hpc Commands Files gathered from the JobConfig File using the keyword in the constructor.  Property will throw if no valid files are found.
        /// </summary>
        public ReadOnlyCollection<string> HpcCommandsFiles
        {
            get 
            {
                if (_hpcCommandsFiles == null)
                    _hpcCommandsFiles = JobConfigurationUtilities.FindAndReadIncludesFilesFromJobConfig(_jobConfigFile, _keyword, HpcCommandsElement, true);
                    
                return _hpcCommandsFiles.ToList().AsReadOnly(); 
            }
        }

        /// <summary>
        /// /// A List of the Protocol Files gathered from the JobConfig File using the keyword in the constructor. Property can return an empty list if No Protocol Defined.
        /// </summary>
        public ReadOnlyCollection<string> ProtocolFiles
        {
            get 
            {
                if (_protocolFiles == null)
                    _protocolFiles = JobConfigurationUtilities.FindAndReadIncludesFilesFromJobConfig(_jobConfigFile, _keyword, ProtocolElement, false);
                
                return _protocolFiles.ToList().AsReadOnly(); 
            }
        }

        #endregion

        #region IDisposable Members

        /// <summary>
        /// Disposes HpcCommandsInfo and its Underlying Streams
        /// </summary>
        public void Dispose()
        {
            if (!_disposed)
            {
                if (_jobConfigFile != null)
                    _jobConfigFile.Dispose();

                if(_hpcCommandsStream != null)
                    _hpcCommandsStream.Dispose();
                
                if(_protocolStream != null)
                    _protocolStream.Dispose();

                _disposed = true;
            }
        }

        #endregion
    }
}
