Files
PowerShell/src/System.Management.Automation/engine/EngineIntrinsics.cs
T
Steve Lee c1c5344a88 Update copyright and license headers (#6134)
Based on standard practices, we need to have a copyright and license notice at the top of each source file. Removed existing copyrights and updated/added copyright notices for .h, .cpp, .cs, .ps1, and .psm1 files.

Updated module manifests for consistency to have Author = "PowerShell" and Company = "Microsoft Corporation". Removed multiple line breaks.

Separate PR coming to update contribution document for new source files: #6140

Manually reviewed each change.

Fix #6073
2018-02-13 09:23:53 -08:00

120 lines
3.3 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
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");
}
_context = context;
_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 { 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
}