/********************************************************************++
Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System.Collections.ObjectModel;
using Dbg = System.Management.Automation;
namespace System.Management.Automation
{
///
/// Exposes the Item noun of the Cmdlet Providers to the Cmdlet base class. The methods of this class
/// use the providers to perform operations.
///
public sealed class ItemCmdletProviderIntrinsics
{
#region Constructors
///
/// Hide the default constructor since we always require an instance of SessionState
///
private ItemCmdletProviderIntrinsics()
{
Dbg.Diagnostics.Assert(
false,
"This constructor should never be called. Only the constructor that takes an instance of SessionState should be called.");
} // CmdletProviderIntrinsics private
///
/// Constructs a facade over the "real" session state API
///
///
///
/// An instance of the cmdlet.
///
///
///
/// If is null.
///
///
internal ItemCmdletProviderIntrinsics(Cmdlet cmdlet)
{
if (cmdlet == null)
{
throw PSTraceSource.NewArgumentNullException("cmdlet");
}
_cmdlet = cmdlet;
_sessionState = cmdlet.Context.EngineSessionState;
} // CmdletProviderIntrinsics internal
///
/// Constructs a facade over the "real" session state API
///
///
///
/// An instance of the "real" session state class.
///
///
///
/// If is null.
///
///
internal ItemCmdletProviderIntrinsics(SessionStateInternal sessionState)
{
if (sessionState == null)
{
throw PSTraceSource.NewArgumentNullException("sessionState");
}
_sessionState = sessionState;
} // CmdletProviderIntrinsics internal
#endregion Constructors
#region Public methods
#region GetItem
///
/// Gets the item at the specified path.
///
///
///
/// The path to the item to retrieve. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The object(s) at the specified path.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Get(string path)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.GetItem(new string[] { path }, false, false);
} // GetItem
///
/// Gets the item at the specified path.
///
///
///
/// The path(s) to the item(s) to retrieve. They may be a drive or provider-qualified path(s) and may include
/// glob characters.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// The object(s) at the specified path.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Get(string[] path, bool force, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.GetItem(path, force, literalPath);
} // GetItem
///
/// Gets the item at the specified path.
///
///
///
/// The path to the item to retrieve. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The object(s) at the specified path are written to the context.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Get(string path, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.GetItem(new string[] { path }, context);
} // GetItem
///
/// Gets the dynamic parameters for the get-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object GetItemDynamicParameters(string path, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.GetItemDynamicParameters(path, context);
} // GetItemDynamicParamters
#endregion GetItem
#region SetItem
///
/// Sets the item at the specified path.
///
///
///
/// The path to the item to set. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The new value to set the item to.
///
///
///
/// The object(s) set at the specified path.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Set(string path, object value)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.SetItem(new string[] { path }, value, false, false);
} // SetItem
///
/// Sets the item at the specified path.
///
///
///
/// The path(s) to the item(s) to set. They may be drive or provider-qualified paths and may include
/// glob characters.
///
///
///
/// The new value to set the item to.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// The object(s) set at the specified path.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Set(string[] path, object value, bool force, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.SetItem(path, value, force, literalPath);
} // SetItem
///
/// Sets the item at the specified path.
///
///
///
/// The path to the item to set. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The new value to set the item to.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The object(s) set at the specified path are written to the context.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Set(string path, object value, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.SetItem(new string[] { path }, value, context);
} // SetItem
///
/// Gets the dynamic parameters for the set-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The new value of the item at the specified path.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object SetItemDynamicParameters(
string path,
object value,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.SetItemDynamicParameters(path, value, context);
} // SetItemDynamicParameters
#endregion SetItem
#region ClearItem
///
/// Clears the item at the specified path.
///
///
///
/// The path to the item to clear. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The object(s) cleared at the specified path.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Clear(string path)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ClearItem(new string[] { path }, false, false);
} // ClearItem
///
/// Clears the item at the specified path.
///
///
///
/// The path(s) to the item to clear. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// The object(s) cleared at the specified path.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Clear(string[] path, bool force, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ClearItem(path, force, literalPath);
} // ClearItem
///
/// Clears the item at the specified path.
///
///
///
/// The path to the item to be cleared. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The object(s) cleared at the specified path are written to the context.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Clear(string path, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.ClearItem(new string[] { path }, context);
} // ClearItem
///
/// Gets the dynamic parameters for the clear-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object ClearItemDynamicParameters(string path, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ClearItemDynamicParameters(path, context);
} // ClearItemDynamicParameters
#endregion ClearItem
#region InvokeDefaultAction
///
/// Invokes the default action of the item at the specified path.
///
///
///
/// The path to the item to invoke. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public void Invoke(string path)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.InvokeDefaultAction(new string[] { path }, false);
} // InvokeDefaultAction
///
/// Invokes the default action of the item(s) at the specified path(s).
///
///
///
/// The path(s) to the item(s) to invoke. They may be drive or provider-qualified paths and may include
/// glob characters.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public void Invoke(string[] path, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.InvokeDefaultAction(path, literalPath);
} // InvokeDefaultAction
///
/// Invokes the default action for the item at the specified path.
///
///
///
/// The path to the item to be invoked. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The context under which the command is running.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Invoke(string path, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.InvokeDefaultAction(new string[] { path }, context);
} // InvokeDefaultAction
///
/// Gets the dynamic parameters for the invoke-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object InvokeItemDynamicParameters(string path, CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.InvokeDefaultActionDynamicParameters(path, context);
} // InvokeItemDynamicParameters
#endregion InvokeDefaultAction
#region RenameItem
///
/// Renames the item at the given path.
///
///
///
/// The path to the item to rename. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The new name of the item.
///
///
///
/// The item(s) that were renamed.
///
///
///
/// If or is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Rename(string path, string newName)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.RenameItem(path, newName, false);
} // RenameItem
///
/// Renames the item at the given path.
///
///
///
/// The path to the item to rename. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The new name of the item.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// The item(s) that were renamed.
///
///
///
/// If or is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Rename(string path, string newName, bool force)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.RenameItem(path, newName, force);
} // RenameItem
///
/// Renames the item at the given path.
///
///
///
/// The path to the item to rename. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The new name of the item.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The item(s) that get renamed are written to the context.
///
///
///
/// If or is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Rename(
string path,
string newName,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.RenameItem(path, newName, context);
} // RenameItem
///
/// Gets the dynamic parameters for the rename-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The new name of the item.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object RenameItemDynamicParameters(
string path,
string newName,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.RenameItemDynamicParameters(path, newName, context);
} // RenameItemDynamicParameters
#endregion RenameItem
#region NewItem
///
/// Creates a new item at the given path.
///
///
///
/// The path to the container to create item in. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The name of the new item to create.
///
///
///
/// The type of the new item to create.
///
///
///
/// The content of the new item to create.
///
///
///
/// The item that was created.
///
///
///
/// If or is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection New(
string path,
string name,
string itemTypeName,
object content)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.NewItem(new string[] { path }, name, itemTypeName, content, false);
} // NewItem
///
/// Creates a new item at the given path.
///
///
///
/// The path(s) to the container to create item in. They may be drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The name of the new item to create.
///
///
///
/// The type of the new item to create.
///
///
///
/// The content of the new item to create.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// The item(s) that was created.
///
///
///
/// If or is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection New(
string[] path,
string name,
string itemTypeName,
object content,
bool force)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.NewItem(path, name, itemTypeName, content, force);
} // NewItem
///
/// Creates a new item at the given path.
///
///
///
/// The path to the container to create item in. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The name of the new item to create.
///
///
///
/// The type of the new item to create.
///
///
///
/// The content of the new item to create.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The new item is written to the context.
///
///
///
/// If or is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void New(
string path,
string name,
string type,
object content,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.NewItem(new string[] { path }, name, type, content, context);
} // NewItem
///
/// Gets the dynamic parameters for the new-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The type of the new item to create.
///
///
///
/// The content of the new item to create.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object NewItemDynamicParameters(
string path,
string type,
object content,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.NewItemDynamicParameters(path, type, content, context);
} // NewItemDynamicParameters
#endregion NewItem
#region RemoveItem
///
/// Removes the items at the given path.
///
///
///
/// The path to the item to remove. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// If true, removes all the children in all the sub-containers of the specified
/// container. If false, only removes the immediate children of the specified
/// container.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public void Remove(string path, bool recurse)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.RemoveItem(new string[] { path }, recurse, false, false);
} // RemoveItem
///
/// Removes the items at the given path.
///
///
///
/// The path(s) to the item(s) to remove. They may be drive or provider-qualified paths and may include
/// glob characters.
///
///
///
/// If true, removes all the children in all the sub-containers of the specified
/// container. If false, only removes the immediate children of the specified
/// container.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public void Remove(string[] path, bool recurse, bool force, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.RemoveItem(path, recurse, force, literalPath);
} // RemoveItem
///
/// Removes the items at the given path.
///
///
///
/// The path to the item to remove. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// If true, removes all the children in all the sub-containers of the specified
/// container. If false, only removes the immediate children of the specified
/// container.
///
///
///
/// The context under which the command is running.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Remove(
string path,
bool recurse,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.RemoveItem(new string[] { path }, recurse, context);
} // RemoveItem
///
/// Gets the dynamic parameters for the remove-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// If true, removes all the children in all the sub-containers of the specified
/// container. If false, only removes the immediate children of the specified
/// container.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object RemoveItemDynamicParameters(
string path,
bool recurse,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.RemoveItemDynamicParameters(path, recurse, context);
} // RemoveItemDynamicParameters
#endregion RemoveItem
#region CopyItem
///
/// Copy item at the specified path
///
///
///
/// The path to the item to copy. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The path to copy the item to.
///
///
///
/// If true, copies all the children in all the sub-containers of the specified
/// container. If false, only copies the specified item.
///
///
///
/// Determines how the source container is used in the copy operation.
///
///
///
/// The item(s) that were copied.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Copy(
string path,
string destinationPath,
bool recurse,
CopyContainers copyContainers)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.CopyItem(new string[] { path }, destinationPath, recurse, copyContainers, false, false);
} // CopyItem
///
/// Copy item at the specified path
///
///
///
/// The path(s) to the item(s) to copy. They may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The path to copy the item to.
///
///
///
/// If true, copies all the children in all the sub-containers of the specified
/// container. If false, only copies the specified item.
///
///
///
/// Determines how the source container is used in the copy operation.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// The item(s) that were copied.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Copy(
string[] path,
string destinationPath,
bool recurse,
CopyContainers copyContainers,
bool force,
bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.CopyItem(path, destinationPath, recurse, copyContainers, force, literalPath);
} // CopyItem
///
/// Copy item at the specified path
///
///
///
/// The path to the item to copy. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The path to copy the item to.
///
///
///
/// If true, copies all the children in all the sub-containers of the specified
/// container. If false, only copies the specified item.
///
///
///
/// Determines how the source container is used in the copy operation.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The item(s) that were copied are written to the context.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Copy(
string path,
string destinationPath,
bool recurse,
CopyContainers copyContainers,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.CopyItem(new string[] { path }, destinationPath, recurse, copyContainers, context);
} // CopyItem
///
/// Gets the dynamic parameters for the copy-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The path to copy the item to.
///
///
///
/// If true, copies all the children in all the sub-containers of the specified
/// container. If false, only copies the specified item.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object CopyItemDynamicParameters(
string path,
string destination,
bool recurse,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.CopyItemDynamicParameters(path, destination, recurse, context);
} // CopyItemDynamicParameters
#endregion CopyItem
#region MoveItem
///
/// Moves the item at the specified path to the specified destination.
///
///
///
/// The path to the item to move.
///
///
///
/// The path to the location that the item will be moved.
///
///
///
/// The item(s) that were moved.
///
///
///
/// If is null.
///
///
///
/// If resolves to multiple paths.
/// or
/// If and don't resolve
/// to the same provider.
/// or
/// If resolves to multiple paths and
/// is not a container.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Move(string path, string destination)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.MoveItem(new string[] { path }, destination, false, false);
} // MoveItem
///
/// Moves the item at the specified path to the specified destination.
///
///
///
/// The path(s) to the item to move.
///
///
///
/// The path to the location that the item will be moved.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// The item(s) that were moved.
///
///
///
/// If is null.
///
///
///
/// If resolves to multiple paths.
/// or
/// If and don't resolve
/// to the same provider.
/// or
/// If resolves to multiple paths and
/// is not a container.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public Collection Move(string[] path, string destination, bool force, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.MoveItem(path, destination, force, literalPath);
} // MoveItem
///
/// Moves the item at the specified path to the specified destination.
///
///
///
/// The path to the item to move.
///
///
///
/// The path to the location that the item will be moved.
///
///
///
/// The context under which the command is running.
///
///
///
/// Nothing. The object that is moved is written to the context.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal void Move(
string path,
string destination,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
_sessionState.MoveItem(new string[] { path }, destination, context);
} // MoveItem
///
/// Gets the dynamic parameters for the move-item cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The path to move the item to.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If does not contain glob characters and
/// could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object MoveItemDynamicParameters(
string path,
string destination,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.MoveItemDynamicParameters(path, destination, context);
} // MoveItemDynamicParameters
#endregion MoveItem
#region Exists
///
/// Determines if an item at the given path exits.
///
///
///
/// The path to the item to determine if it exists. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// True if the item at the specified path exists. False otherwise.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public bool Exists(string path)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ItemExists(path, false, false);
} // ItemExists
///
/// Determines if an item at the given path exits.
///
///
///
/// The path to the item to determine if it exists. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// Passed on to providers to force operations.
///
///
///
/// If true, globbing is not done on paths.
///
///
///
/// True if the item at the specified path exists. False otherwise.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public bool Exists(string path, bool force, bool literalPath)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ItemExists(path, force, literalPath);
} // ItemExists
///
/// Determines if an item at the given path exits.
///
///
///
/// The path to the item to determine if it exists. It may be a drive or provider-qualified path and may include
/// glob characters.
///
///
///
/// The context under which the command is running.
///
///
///
/// True if the item at the specified path exists. False otherwise.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal bool Exists(
string path,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ItemExists(path, context);
} // ItemExists
///
/// Gets the dynamic parameters for the test-path cmdlet.
///
///
///
/// The path to the item if it was specified on the command line.
///
///
///
/// The context which the core command is running.
///
///
///
/// An object that has properties and fields decorated with
/// parsing attributes similar to a cmdlet class.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal object ItemExistsDynamicParameters(
string path,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.ItemExistsDynamicParameters(path, context);
} // ItemExistsDynamicParameters
#endregion ItemExists
#region IsContainer
///
/// Determines if the specified path is to an item that is a container.
///
///
///
/// The path to the item to determine if it is a container.
///
///
///
/// True if the path is to an item that is a container. False otherwise.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
public bool IsContainer(string path)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.IsItemContainer(path);
} // IsItemContainer
///
/// Determines if the specified path is to an item that is a container.
///
///
///
/// The path to the item to determine if it is a container.
///
///
///
/// The context under which the command is running.
///
///
///
/// True if the path is to an item that is a container. False otherwise.
///
///
///
/// If is null.
///
///
///
/// If the refers to a provider that could not be found.
///
///
///
/// If the refers to a drive that could not be found.
///
///
///
/// If the provider that the refers to does
/// not support this operation.
///
///
///
/// If the provider threw an exception.
///
internal bool IsContainer(
string path,
CmdletProviderContext context)
{
Dbg.Diagnostics.Assert(
_sessionState != null,
"The only constructor for this class should always set the sessionState field");
// Parameter validation is done in the session state object
return _sessionState.IsItemContainer(path, context);
} // IsItemContainer
#endregion IsItemContainer
#endregion Public methods
#region private data
private Cmdlet _cmdlet;
private SessionStateInternal _sessionState;
#endregion private data
} // ItemCmdletProviderIntrinsics
///
/// Determines how the source container of a copy operation
/// will be used.
///
public enum CopyContainers
{
///
/// The source container is copied.
///
CopyTargetContainer,
///
/// The children of the source contianer are copied.
///
CopyChildrenOfTargetContainer
}
}