/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ using System.Collections.ObjectModel; using Dbg = System.Management.Automation; namespace System.Management.Automation { /// /// Exposes the Property noun of the Cmdlet Providers to the Cmdlet base class. The methods of this class /// use the providers to perform operations. /// public sealed class PropertyCmdletProviderIntrinsics { #region Constructors /// /// Hide the default constructor since we always require an instance of SessionState /// private PropertyCmdletProviderIntrinsics() { 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 PropertyCmdletProviderIntrinsics(Cmdlet cmdlet) { if (cmdlet == null) { throw PSTraceSource.NewArgumentNullException("cmdlet"); } _cmdlet = cmdlet; _sessionState = cmdlet.Context.EngineSessionState; } // PropertyCmdletProviderIntrinsics internal /// /// Constructs a facade over the "real" session state API /// /// /// /// An instance of the "real" session state. /// /// /// /// If is null. /// /// internal PropertyCmdletProviderIntrinsics(SessionStateInternal sessionState) { if (sessionState == null) { throw PSTraceSource.NewArgumentNullException("sessionState"); } _sessionState = sessionState; } // PropertyCmdletProviderIntrinsics internal #endregion Constructors #region Public methods #region GetProperty /// /// Gets the specified properties from the specified item(s) /// /// /// /// The path to the item to get the properties from. /// /// /// /// The properties to get from the item(s). If this is empty, null, or "*" all /// properties should be returned. /// /// /// /// A PSObject for each item that the path represents. Each PSObject should /// contain a property for those in the providerSpecificPickList. /// /// /// /// 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, Collection providerSpecificPickList) { 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.GetProperty(new string[] { path }, providerSpecificPickList, false); } // GetProperty /// /// Gets the specified properties from the specified item(s) /// /// /// /// The path(s) to the item(s) to get the properties from. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// The properties to get from the item(s). If this is empty, null, or "*" all /// properties should be returned. /// /// /// /// A PSObject for each item that the path represents. Each PSObject should /// contain a property for those in the providerSpecificPickList. /// /// /// /// 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, Collection providerSpecificPickList, 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.GetProperty(path, providerSpecificPickList, literalPath); } // GetProperty /// /// Gets the specified properties from the specified item(s) /// /// /// /// The path to the item to get the properties from. /// /// /// /// The properties to get from the item(s). If this is empty, null, or "*" all /// properties should be returned. /// /// /// /// The context under which the command is running. /// /// /// /// Nothing. A PSObject for each item that the path represents is written /// to the context. Each PSObject should /// contain a property for those in the providerSpecificPickList. /// /// /// /// 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, Collection providerSpecificPickList, 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.GetProperty(new string[] { path }, providerSpecificPickList, context); } // GetProperty /// /// Gets the dynamic parameters for the get-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The properties to get from the item(s). If this is empty, null, or "*" all /// properties should be returned. /// /// /// /// 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 GetPropertyDynamicParameters( string path, Collection providerSpecificPickList, 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.GetPropertyDynamicParameters(path, providerSpecificPickList, context); } // GetPropertyDynamicParameters #endregion GetProperty #region SetProperty /// /// Sets the specified properties on the specified item(s) /// /// /// /// The path to the item to set the properties on. /// /// /// /// The properties that are to be set on the item /// /// /// /// A PSObject for each item that had the property set on it. /// /// /// /// 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 Set( string path, PSObject propertyValue) { 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.SetProperty(new string[] { path }, propertyValue, false, false); } // SetProperty /// /// Sets the specified properties on the specified item(s) /// /// /// /// The path(s) to the item(s) to set the properties on. /// /// /// /// The properties that are to be set on the item /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// A PSObject for each item that had the property set on it. /// /// /// /// 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 Set( string[] path, PSObject propertyValue, 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.SetProperty(path, propertyValue, force, literalPath); } // SetProperty /// /// Sets the specified properties on the specified item(s) /// /// /// /// The path to the item to set the properties on. /// /// /// /// The properties that are to be set on the item /// /// /// /// The context under which the command is running. /// /// /// /// Nothing. A PSObject for the property that was set 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 Set( string path, PSObject propertyValue, 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.SetProperty(new string[] { path }, propertyValue, context); } // SetProperty /// /// Gets the dynamic parameters for the set-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The properties that are to be set on 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 SetPropertyDynamicParameters( string path, PSObject propertyValue, 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.SetPropertyDynamicParameters(path, propertyValue, context); } // SetPropertyDynamicParameters #endregion SetProperty #region ClearProperty /// /// Clear the specified properties from the specified item(s) /// /// /// /// The path to the item to clear the properties from. /// /// /// /// The properties to clear from the item(s). /// /// /// /// 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 void Clear( string path, Collection propertyToClear) { 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.ClearProperty(new string[] { path }, propertyToClear, false, false); } // ClearProperty /// /// Clear the specified properties from the specified item(s) /// /// /// /// The path(s) to the item(s) to clear the properties from. /// /// /// /// The properties to clear from the item(s). /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// 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 void Clear( string[] path, Collection propertyToClear, 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.ClearProperty(path, propertyToClear, force, literalPath); } // ClearProperty /// /// Clears the specified properties from the specified item(s) /// /// /// /// The path to the item to clear the properties from. /// /// /// /// The properties to clear from the item(s). /// /// /// /// The context under which the command is running. /// /// /// /// 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 Clear( string path, Collection propertyToClear, 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.ClearProperty(new string[] { path }, propertyToClear, context); } // ClearProperty /// /// Gets the dynamic parameters for the clear-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The properties to clear from the item(s). /// /// /// /// 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 ClearPropertyDynamicParameters( string path, Collection propertyToClear, 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.ClearPropertyDynamicParameters(path, propertyToClear, context); } // ClearPropertyDynamicParameters #endregion ClearProperty #region NewProperty /// /// Creates a new property on the specified item /// /// /// /// The path to the item on which the new property should be created. /// /// /// /// The name of the property that should be created. /// /// /// /// The type of the property that should be created. /// /// /// /// The new value of the property that should be created. /// /// /// /// A PSObject for each item that the property was created on. The PSObject /// contains the properties that were created. /// /// /// /// 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 New( string path, string propertyName, string propertyTypeName, 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.NewProperty(new string[] { path }, propertyName, propertyTypeName, value, false, false); } // NewProperty /// /// Creates a new property on the specified item /// /// /// /// The path(s) to the item(s0 on which the new property should be created. /// /// /// /// The name of the property that should be created. /// /// /// /// The type of the property that should be created. /// /// /// /// The new value of the property that should be created. /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// A PSObject for each item that the property was created on. The PSObject /// contains the properties that were created. /// /// /// /// 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 New( string[] path, string propertyName, string propertyTypeName, 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.NewProperty(path, propertyName, propertyTypeName, value, force, literalPath); } // NewProperty /// /// Creates a new property on the specified item /// /// /// /// The path to the item on which the new property should be created. /// /// /// /// The name of the property that should be created. /// /// /// /// The type of the property that should be created. /// /// /// /// The new value of the property that should be created. /// /// /// /// The context under which the command is running. /// /// /// /// Nothing. A PSObject for each item that the property was created on /// is written to the context. Each PSObject /// contains the properties that were created. /// /// /// /// 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 New( string path, string propertyName, string type, 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.NewProperty(new string[] { path }, propertyName, type, value, context); } // NewProperty /// /// Gets the dynamic parameters for the new-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The name of the property that should be created. /// /// /// /// The type of the property that should be created. /// /// /// /// The new value of the property that should be created. /// /// /// /// 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 NewPropertyDynamicParameters( string path, string propertyName, string type, 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.NewPropertyDynamicParameters(path, propertyName, type, value, context); } // NewPropertyDynamicParameters #endregion NewProperty #region RemoveProperty /// /// Removes a property from the specified item(s) /// /// /// /// The path to the item(s) on which the property should be removed. /// /// /// /// The property name that should be removed. /// /// /// /// 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 void Remove(string path, string propertyName) { 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.RemoveProperty(new string[] { path }, propertyName, false, false); } // RemoveProperty /// /// Removes a property from the specified item(s) /// /// /// /// The path(s) to the item(s) on which the property should be removed. /// /// /// /// The property name that should be removed. /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// 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 void Remove(string[] path, string propertyName, 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.RemoveProperty(path, propertyName, force, literalPath); } // RemoveProperty /// /// Removes a property from the specified item(s) /// /// /// /// The path to the item(s) on which the property should be removed. /// /// /// /// The property name that should be removed. /// /// /// /// The context under which the command is running. /// /// /// /// 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 Remove( string path, string propertyName, 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.RemoveProperty(new string[] { path }, propertyName, context); } // RemoveProperty /// /// Gets the dynamic parameters for the remove-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The name of the property that should be removed. /// /// /// /// 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 RemovePropertyDynamicParameters( string path, string propertyName, 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.RemovePropertyDynamicParameters(path, propertyName, context); } // RemovePropertyDynamicParameters #endregion RemoveProperty #region RenameProperty /// /// Renames a property on the specified item(s) /// /// /// /// The path to the item(s) on which the property should be renamed. /// /// /// /// The source name of the property to be renamed. /// /// /// /// The new name of the property. /// /// /// /// A PSObject for each item that is the new property after the rename. /// /// /// /// 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 sourceProperty, string destinationProperty) { 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.RenameProperty(new string[] { path }, sourceProperty, destinationProperty, false, false); } // RenameProperty /// /// Renames a property on the specified item(s) /// /// /// /// The path(s) to the item(s) on which the property should be renamed. /// /// /// /// The source name of the property to be renamed. /// /// /// /// The new name of the property. /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// A PSObject for each item that is the new property after the rename. /// /// /// /// 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 sourceProperty, string destinationProperty, 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.RenameProperty(path, sourceProperty, destinationProperty, force, literalPath); } // RenameProperty /// /// Renames a property on the specified item(s) /// /// /// /// The path to the item(s) on which the property should be renamed. /// /// /// /// The source name of the property to be renamed. /// /// /// /// The new name of the property. /// /// /// /// The context under which the command is running. /// /// /// /// Nothing. A PSObject for each item that the property is renamed on is /// written to the context. The Shellobject contains the new property after the rename. /// /// /// /// 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 sourceProperty, string destinationProperty, 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.RenameProperty(new string[] { path }, sourceProperty, destinationProperty, context); } // RenameProperty /// /// Gets the dynamic parameters for the rename-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The source name of the property to be renamed. /// /// /// /// The new name of the property. /// /// /// /// 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 RenamePropertyDynamicParameters( string path, string sourceProperty, string destinationProperty, 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.RenamePropertyDynamicParameters(path, sourceProperty, destinationProperty, context); } // RenamePropertyDynamicParameters #endregion RenameProperty #region CopyProperty /// /// Copies a property on the specified item(s) /// /// /// /// The path to the item(s) on which the property should be copied. /// /// /// /// The source name of the property to be copied. /// /// /// /// The path to the item(s) to copy the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// A PSObject for each item that is the new property after the copy. /// /// /// /// 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 Copy( string sourcePath, string sourceProperty, string destinationPath, string destinationProperty) { 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.CopyProperty( new string[] { sourcePath }, sourceProperty, destinationPath, destinationProperty, false, false); } // CopyProperty /// /// Copies a property on the specified item(s) /// /// /// /// The path(s) to the item(s) on which the property should be copied. /// /// /// /// The source name of the property to be copied. /// /// /// /// The path to the item(s) to copy the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// A PSObject for each item that is the new property after the copy. /// /// /// /// 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 Copy( string[] sourcePath, string sourceProperty, string destinationPath, string destinationProperty, 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.CopyProperty( sourcePath, sourceProperty, destinationPath, destinationProperty, force, literalPath); } // CopyProperty /// /// Copies a property on the specified item(s) /// /// /// /// The path to the item(s) on which the property should be copied. /// /// /// /// The source name of the property to be copied. /// /// /// /// The path to the item(s) to copy the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// The context under which the command is running. /// /// /// /// Nothing. A PSObject for each item that the new property was copied to 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 Copy( string sourcePath, string sourceProperty, string destinationPath, string destinationProperty, 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.CopyProperty( new string[] { sourcePath }, sourceProperty, destinationPath, destinationProperty, context); } // CopyProperty /// /// Gets the dynamic parameters for the copy-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The source name of the property to be copied. /// /// /// /// The path to the item(s) to copy the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// 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 CopyPropertyDynamicParameters( string path, string sourceProperty, string destinationPath, string destinationProperty, 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.CopyPropertyDynamicParameters(path, sourceProperty, destinationPath, destinationProperty, context); } // CopyPropertyDynamicParameters #endregion CopyProperty #region MoveProperty /// /// Moves a property on the specified item(s) /// /// /// /// The path to the item(s) on which the property should be moved. /// /// /// /// The source name of the property to be moved. /// /// /// /// The path to the item(s) to move the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// A PSObject for each item that is the new property after the move. /// /// /// /// If , , /// , or /// is null. /// /// /// /// If resolves to more than one item. /// /// /// /// 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 sourcePath, string sourceProperty, string destinationPath, string destinationProperty) { 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.MoveProperty( new string[] { sourcePath }, sourceProperty, destinationPath, destinationProperty, false, false); } // MoveProperty /// /// Moves a property on the specified item(s) /// /// /// /// The path(s) to the item(s) on which the property should be moved. /// /// /// /// The source name of the property to be moved. /// /// /// /// The path to the item(s) to move the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// Passed on to providers to force operations. /// /// /// /// If true, globbing is not done on paths. /// /// /// /// A PSObject for each item that is the new property after the move. /// /// /// /// If , , /// , or /// is null. /// /// /// /// If resolves to more than one item. /// /// /// /// 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[] sourcePath, string sourceProperty, string destinationPath, string destinationProperty, 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.MoveProperty( sourcePath, sourceProperty, destinationPath, destinationProperty, force, literalPath); } // MoveProperty /// /// Moves a property on the specified item(s) /// /// /// /// The path to the item(s) on which the property should be moved. /// /// /// /// The source name of the property to be moved. /// /// /// /// The path to the item(s) to move the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// The context under which the command is running. /// /// /// /// Nothing. A PSObject for each item that the property was moved to is written /// to the context. /// /// /// /// If , , /// , or /// is null. /// /// /// /// If resolves to more than one item. /// /// /// /// 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 sourcePath, string sourceProperty, string destinationPath, string destinationProperty, 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.MoveProperty( new string[] { sourcePath }, sourceProperty, destinationPath, destinationProperty, context); } // MoveProperty /// /// Gets the dynamic parameters for the copy-itemproperty cmdlet. /// /// /// /// The path to the item if it was specified on the command line. /// /// /// /// The source name of the property to be moved. /// /// /// /// The path to the item(s) to move the property to. It can be the same /// as the sourcePath as long as the destinationProperty is different. /// /// /// /// The new name of the property. /// /// /// /// 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 MovePropertyDynamicParameters( string path, string sourceProperty, string destinationPath, string destinationProperty, 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.MovePropertyDynamicParameters(path, sourceProperty, destinationPath, destinationProperty, context); } // MovePropertyDynamicParameters #endregion MoveProperty #endregion Public methods #region private data private Cmdlet _cmdlet; private SessionStateInternal _sessionState; #endregion private data } // PropertyCmdletProviderIntrinsics }