/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ using System.Management.Automation.Host; using Dbg = System.Management.Automation; namespace System.Management.Automation { /// /// Exposes the Engine APIs for a particular instance of the engine /// public class EngineIntrinsics { #region Constructors /// /// Hide the default constructor since we always require an instance of ExecutionContext /// private EngineIntrinsics() { Dbg.Diagnostics.Assert( false, "This constructor should never be called. Only the constructor that takes an instance of ExecutionContext should be called."); } /// /// The internal constructor for this object. It should be the only one that gets called. /// /// /// /// An instance of ExecutionContext that the APIs should work against. /// /// /// /// If is null. /// /// internal EngineIntrinsics(ExecutionContext context) { if (context == null) { throw new ArgumentNullException("context"); } _context = context; _host = context.EngineHostInterface; } #endregion Constructors #region Public methods /// /// Gets engine APIs to access the host /// public PSHost Host { get { Dbg.Diagnostics.Assert( _host != null, "The only constructor for this class should always set the host field"); return _host; } // get } // Host /// /// Gets engine APIs to access the event manager /// public PSEventManager Events { get { return _context.Events; } // get } // Host /// /// Gets the engine APIs to access providers /// public ProviderIntrinsics InvokeProvider { get { return _context.EngineSessionState.InvokeProvider; } } // InvokeProvider /// /// Gets the engine APIs to access session state /// public SessionState SessionState { get { return _context.EngineSessionState.PublicSessionState; } } // SessionState /// /// Gets the engine APIs to invoke a command /// public CommandInvocationIntrinsics InvokeCommand { get { return _invokeCommand ?? (_invokeCommand = new CommandInvocationIntrinsics(_context)); } } #endregion Public methods #region private data private ExecutionContext _context; private PSHost _host; private CommandInvocationIntrinsics _invokeCommand; #endregion private data } // EngineIntrinsics }