Files
PowerShell-PowerShell/src/System.Management.Automation/engine/EngineIntrinsics.cs
T
PowerShell Team 60b3b304f2 Move files from psl-monad submodule to super-project
This commit uses psl-monad branch source-depot 7209cb9
And corresponds to [SD:688741]
2016-03-30 17:16:23 -07:00

127 lines
3.6 KiB
C#

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