diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetChildrenCommand.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetChildrenCommand.cs index 591d6e00370..566ec8929f7 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/GetChildrenCommand.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/GetChildrenCommand.cs @@ -30,21 +30,6 @@ public class GetChildItemCommand : CoreCommandBase private const string childrenSet = "Items"; private const string literalChildrenSet = "LiteralItems"; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// The string declaration for the -relationship parameter set. - /// - /// - /// - /// The "relationship" parameter set includes the following parameters: - /// -relationship - /// -property - /// - /// - private const string relationshipSet = "Relationship"; -#endif #region Command parameters /// @@ -214,51 +199,6 @@ public SwitchParameter Name } } -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// Gets and sets the value of the Relationship parameter which determines - /// which relationship the targets should be retrieved for. - /// - /// - [Parameter( - Mandatory = true, - ParameterSetName = relationshipSet, - ValueFromPipelineByPropertyName = true)] - public string[] Relationship - { - get - { - return relationships; - } - set - { - relationships = value; - } - } - private string[] relationships = new string[0]; - - /// - /// Gets or sets the property parameter which may provide guidance to the relationship - /// provider on which targets to return. - /// - /// - [Parameter(ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Property - { - get - { - return property; - } - - set - { - property = value; - } - } - private string property = String.Empty; -#endif /// /// A virtual method for retrieving the dynamic parameters for a cmdlet. Derived cmdlets /// that require dynamic parameters should override this method and return the @@ -302,13 +242,6 @@ internal override object GetDynamicParameters(CmdletProviderContext context) } break; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - case relationshipSet: - // No possible dynamic parameters for the relationship set. - break; -#endif default: result = InvokeProvider.ChildItem.GetChildItemsDynamicParameters(path, Recurse, context); break; @@ -421,63 +354,6 @@ protected override void ProcessRecord() break; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - case relationshipSet: - foreach (string relationship in relationships) - { - Collection results = null; - - try - { - results = - InvokeProvider.Relationship.GetTargets( - relationship, - path, - property); - } - catch (PSArgumentException argException) - { - WriteError( - new ErrorRecord( - argException.ErrorRecord, - argException)); - continue; - } - catch (ProviderNotFoundException providerNotFound) - { - WriteError( - new ErrorRecord( - providerNotFound.ErrorRecord, - providerNotFound)); - continue; - } - - foreach (string target in results) - { - // Create an PSObject with the result. - // Attach the relationship name as a note, - // and set "System.Management.Automation.RelationshipTarget" - // as the TreatAs. - - PSObject result = PSObject.AsPSObject (target); - result.Properties.Add ( - new PSNoteProperty ( - "Relationship", - relationship)); - - Collection treatAs = new Collection (); - treatAs.Add (targetTreatAsType); - - result.TypeNames = treatAs; - - // Now write out the result - WriteObject (result); - } - } - break; -#endif default: Dbg.Diagnostics.Assert( false, @@ -487,11 +363,6 @@ protected override void ProcessRecord() } } // ProcessRecord -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - private const string targetTreatAsType = "System.Management.Automation.RelationshipTarget"; -#endif #endregion command code } // class GetChildrenCommand } // namespace Microsoft.PowerShell.Commands diff --git a/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs b/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs index 4b22d9150bc..e16d512b1f1 100644 --- a/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs +++ b/src/Microsoft.PowerShell.Commands.Management/commands/management/Navigation.cs @@ -745,22 +745,9 @@ public class SetLocationCommand : CoreCommandBase /// private const string stackSet = "Stack"; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// The string declaration for the Relationship parameter set in this command. - /// - private const string relationshipSet = "Relationship"; -#endif /// /// Gets or sets the path property /// -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - [Parameter(Position = 0, ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] -#endif [Parameter(Position = 0, ParameterSetName = pathSet, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] public string Path @@ -813,68 +800,6 @@ public SwitchParameter PassThru [Parameter(ParameterSetName = stackSet, ValueFromPipelineByPropertyName = true)] public string StackName { get; set; } -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// Gets or sets the relationship Parameter which determines which relationship - /// to resolve to a path to set-location to. - /// - /// - [Parameter(Mandatory = true, ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Relationship - { - get - { - return relationship; - } - - set - { - relationship = value; - } - } - private string relationship = String.Empty; - - - /// - /// Gets or sets the Property parameter value - /// - /// - [Parameter(ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Property - { - get - { - return property; - } - - set - { - property = value; - } - } - private string property = String.Empty; - - /// - /// Gets or sets the Target parameter value - /// - /// - [Parameter (ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Target - { - get - { - return target; - } - - set - { - target = value; - } - } - private string target = String.Empty; -#endif #endregion Command parameters #region Command data @@ -971,76 +896,6 @@ protected override void ProcessRecord() break; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - case relationshipSet: - string relationshipPath = null; - try - { - relationshipPath = - InvokeProvider.Relationship.Resolve( - Relationship, - Path, - Property, - Target); - } - catch (PSArgumentException argException) - { - WriteError( - new ErrorRecord( - argException.ErrorRecord, - argException)); - return; - } - - try - { - result = SessionState.Path.SetLocation (relationshipPath, CmdletProviderContext); - } - catch (PSNotSupportedException notSupported) - { - WriteError( - new ErrorRecord( - notSupported.ErrorRecord, - notSupported)); - return; - } - catch (DriveNotFoundException driveNotFound) - { - WriteError( - new ErrorRecord( - driveNotFound.ErrorRecord, - driveNotFound)); - return; - } - catch (ProviderNotFoundException providerNotFound) - { - WriteError( - new ErrorRecord( - providerNotFound.ErrorRecord, - providerNotFound)); - return; - } - catch (PSArgumentException argException) - { - WriteError( - new ErrorRecord( - argException.ErrorRecord, - argException)); - return; - } - catch (ItemNotFoundException pathNotFound) - { - WriteError( - new ErrorRecord( - pathNotFound.ErrorRecord, - pathNotFound)); - return; - } - - break; -#endif default: Dbg.Diagnostics.Assert( false, @@ -1070,18 +925,9 @@ public class PushLocationCommand : CoreCommandBase { #region Command parameters -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - private const string relationshipSet = "Relationship"; -#endif - /// /// Gets or sets the path property /// -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - [Parameter (Position = 0, ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] -#endif [Parameter(Position = 0, ParameterSetName = "Path", ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] public string Path @@ -1139,10 +985,6 @@ public SwitchParameter PassThru /// to use for the push. If the parameter is missing or empty the default /// location stack is used. /// -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - [Parameter (ParameterSetName = relationshipSet)] -#endif [Parameter(ValueFromPipelineByPropertyName = true)] public string StackName { @@ -1156,67 +998,6 @@ public string StackName } //set } // StackName -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// Gets or sets the relationship Parameter which determines which relationship - /// to resolve to a path to set-location to. - /// - /// - [Parameter (Mandatory = true, ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Relationship - { - get - { - return relationship; - } - - set - { - relationship = value; - } - } - private string relationship = String.Empty; - - /// - /// Gets or sets the Property parameter value - /// - /// - [Parameter (ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Property - { - get - { - return property; - } - - set - { - property = value; - } - } - private string property = String.Empty; - - /// - /// Gets or sets the Target parameter value - /// - /// - [Parameter (ParameterSetName = relationshipSet, ValueFromPipelineByPropertyName = true)] - public string Target - { - get - { - return target; - } - - set - { - target = value; - } - } - private string target = String.Empty; -#endif #endregion Command parameters #region Command data @@ -1251,42 +1032,6 @@ protected override void ProcessRecord() // working directory stack SessionState.Path.PushCurrentLocation(_stackName); -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - if (String.Equals( - relationshipSet, - ParameterSetName, - StringComparison.OrdinalIgnoreCase)) - { - try - { - Path = - InvokeProvider.Relationship.Resolve( - Relationship, - Path, - Property, - Target); - } - catch (ProviderNotFoundException providerNotFound) - { - WriteError( - new ErrorRecord( - providerNotFound.ErrorRecord, - providerNotFound)); - - return; - } - catch (PSArgumentException argException) - { - WriteError( - new ErrorRecord( - argException.ErrorRecord, - argException)); - return; - } - } -#endif if (Path != null) { try diff --git a/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs b/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs index 861254af21c..e03ae8f5643 100644 --- a/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs +++ b/src/System.Management.Automation/engine/CmdletFamilyProviderInterfaces.cs @@ -50,15 +50,7 @@ internal ProviderIntrinsics(Cmdlet cmdlet) ChildItem = new ChildItemCmdletProviderIntrinsics(cmdlet); Content = new ContentCmdletProviderIntrinsics(cmdlet); Property = new PropertyCmdletProviderIntrinsics(cmdlet); -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - this.propertyValue = new PropertyValueCmdletProviderIntrinsics(cmdlet); -#endif SecurityDescriptor = new SecurityDescriptorCmdletProviderIntrinsics(cmdlet); - -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - this.relationship = new RelationshipProviderIntrinsics(cmdlet.Context.EngineSessionState); -#endif } // ProviderIntrinsics internal /// @@ -80,15 +72,7 @@ internal ProviderIntrinsics(SessionStateInternal sessionState) ChildItem = new ChildItemCmdletProviderIntrinsics(sessionState); Content = new ContentCmdletProviderIntrinsics(sessionState); Property = new PropertyCmdletProviderIntrinsics(sessionState); -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - this.propertyValue = new PropertyValueCmdletProviderIntrinsics(sessionState); -#endif SecurityDescriptor = new SecurityDescriptorCmdletProviderIntrinsics(sessionState); - -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - this.relationship = new RelationshipProviderIntrinsics(sessionState); -#endif } // ProviderIntrinsics internal #endregion Constructors @@ -115,47 +99,17 @@ internal ProviderIntrinsics(SessionStateInternal sessionState) /// public PropertyCmdletProviderIntrinsics Property { get; } -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - /// - /// The object that exposes the verbs for the item propertyvalue for Cmdlet Providers - /// - /// - public PropertyValueCmdletProviderIntrinsics PropertyValue - { - get { return propertyValue; } - } -#endif - /// /// Gets the object that exposes the verbs for the SecurityDescriptor noun for Cmdlet Providers /// public SecurityDescriptorCmdletProviderIntrinsics SecurityDescriptor { get; } -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// The object that exposes the verbs for the relationship providers - /// - /// - public RelationshipProviderIntrinsics Relationship - { - get { return relationship; } - } -#endif #endregion Public members #region private data private InternalCommand _cmdlet; -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - private PropertyValueCmdletProviderIntrinsics propertyValue; -#endif - -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - private RelationshipProviderIntrinsics relationship = null; -#endif + #endregion private data } // ProviderIntrinsics } diff --git a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs index 8626060c732..a8286ec146d 100644 --- a/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs +++ b/src/System.Management.Automation/engine/DataStoreAdapterProvider.cs @@ -420,9 +420,6 @@ internal ProviderInfo( HelpFile = helpFile; PSSnapIn = psSnapIn; -#if SUPPORTS_CMDLETPROVIDER_FILE - LoadProviderFromPath(path); -#endif // Create the hidden drive. The name doesn't really // matter since we are not adding this drive to a scope. @@ -444,58 +441,6 @@ internal ProviderInfo( } } -#if SUPPORTS_CMDLETPROVIDER_FILE - /// - /// Loads the provider from the specified path. - /// - /// - /// - /// The path to a .cmdletprovider file to load the provider from. - /// - /// - /// - /// If is null or empty. - /// - /// - /// - /// The file specified by could - /// not be loaded as an XML document. - /// - /// - /// - /// If refers to a file that does - /// not adhere to the appropriate CmdletProvider file format. - /// - /// - private void LoadProviderFromPath(string path) - { - if (String.IsNullOrEmpty(path)) - { - throw tracer.NewArgumentException("path"); - } - - Internal.CmdletProviderFileReader reader = - Internal.CmdletProviderFileReader.CreateCmdletProviderFileReader(path); - - // Read the assembly info from the file - assemblyInfo = reader.AssemblyInfo; - - // Read the type name from the file - providerImplementationClassName = reader.TypeName; - - helpFile = reader.HelpFilePath; - - // Read the capabilities from the file - capabilities = reader.Capabilities; - capabilitiesRead = true; - - if (String.IsNullOrEmpty(name)) - { - name = reader.Name; - } - } // LoadProviderFromPath -#endif - /// /// Determines if the passed in name is either the fully-qualified pssnapin name or /// short name of the provider. diff --git a/src/System.Management.Automation/engine/SessionState.cs b/src/System.Management.Automation/engine/SessionState.cs index 41ef431729e..9070f0e2071 100644 --- a/src/System.Management.Automation/engine/SessionState.cs +++ b/src/System.Management.Automation/engine/SessionState.cs @@ -485,20 +485,6 @@ private SessionStateEntryVisibility checkPathVisibility(List list, strin return SessionStateEntryVisibility.Private; } -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// Gets the collection of relationship providers - /// - /// - internal RelationshipProviderCollection Relationships - { - get { return relationships; } - } - private RelationshipProviderCollection relationships = null; -#endif - #endregion Private data /// diff --git a/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs b/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs index ecf08f93791..311be3a90b6 100644 --- a/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs +++ b/src/System.Management.Automation/engine/SessionStateProviderAPIs.cs @@ -1436,14 +1436,6 @@ internal ProviderInfo NewProvider(ProviderInfo provider) } } -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - // Make sure the delay-load relationships get updated for the new provider - - relationships.ProcessDelayLoadRelationships (provider.Name); -#endif - // Now write out the result return provider; @@ -1761,13 +1753,6 @@ internal void RemoveProvider( RemoveProviderFromCollection(provider); ProvidersCurrentWorkingDrive.Remove(provider); - -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - // Now make sure no relationship reference this provider - relationships.ProcessRelationshipsOnCmdletProviderRemoval (providerName); -#endif } } } // RemoveProvider diff --git a/src/System.Management.Automation/engine/SessionStatePublic.cs b/src/System.Management.Automation/engine/SessionStatePublic.cs index e032b115aa0..e1bf6cbd26c 100644 --- a/src/System.Management.Automation/engine/SessionStatePublic.cs +++ b/src/System.Management.Automation/engine/SessionStatePublic.cs @@ -35,12 +35,6 @@ internal SessionState(SessionStateInternal sessionState) } _sessionState = sessionState; - -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - this.relationship = new RelationshipProviderManagementIntrinsics (sessionState); -#endif } // SessionState /// @@ -305,28 +299,6 @@ public static bool IsVisible(CommandOrigin origin, CommandInfo commandInfo) return (commandInfo.Visibility == SessionStateEntryVisibility.Public); } -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// The state APIs to access relationship providers in session state. - /// - /// - public RelationshipProviderManagementIntrinsics Relationship - { - get - { - using (tracer.TraceProperty()) - { - Dbg.Diagnostics.Assert ( - relationship != null, - "The only constructor for this class should always set the relationship field"); - - return relationship; - } // TraceProperty - } // get - } // RelationshipProvider -#endif #endregion Public methods #region Internal methods @@ -349,12 +321,6 @@ internal SessionStateInternal Internal private PathIntrinsics _path; private PSVariableIntrinsics _variable; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - private RelationshipProviderManagementIntrinsics relationship = null; -#endif - #endregion private data } // SessionStatePublic diff --git a/src/System.Management.Automation/engine/SessionStateStrings.cs b/src/System.Management.Automation/engine/SessionStateStrings.cs index f3b0330eee0..6ee16046379 100644 --- a/src/System.Management.Automation/engine/SessionStateStrings.cs +++ b/src/System.Management.Automation/engine/SessionStateStrings.cs @@ -86,15 +86,6 @@ internal static class StringLiterals /// internal const string SessionState = "SessionState"; -#if RELATIONSHIP_SUPPORTED - // 2004/11/24-JeffJon - Relationships have been removed from the Exchange release - - /// - /// The file extension (including the dot) of the relationship provider description file - /// - internal const string RelationshipProviderFileExtension = ".relationshipprovider"; -#endif - /// /// The file extension (including the dot) of an PowerShell script file /// diff --git a/src/System.Management.Automation/namespaces/Buffer.cs b/src/System.Management.Automation/namespaces/Buffer.cs deleted file mode 100644 index 81a4de05b0e..00000000000 --- a/src/System.Management.Automation/namespaces/Buffer.cs +++ /dev/null @@ -1,294 +0,0 @@ - -// -// NOTE: A vast majority of this code was copied from BCL in -// Namespace: System -// - -using BCLDebug = System.Diagnostics.Debug; -using System.Runtime.ConstrainedExecution; - -namespace Microsoft.PowerShell.Commands.Internal -{ - //Only contains static methods. Does not require serialization - - [System.Runtime.InteropServices.ComVisible(true)] - internal static class Buffer - { - // This is ported from the optimized CRT assembly in memchr.asm. The JIT generates - // pretty good code here and this ends up being within a couple % of the CRT asm. - // It is however cross platform as the CRT hasn't ported their fast version to 64-bit - // platforms. - // - internal static unsafe int IndexOfByte(byte* src, byte value, int index, int count) - { - BCLDebug.Assert(src != null, "src should not be null"); - - byte* pByte = src + index; - - // Align up the pointer to sizeof(int). - while (((int)pByte & 3) != 0) - { - if (count == 0) - return -1; - else if (*pByte == value) - return (int)(pByte - src); - - count--; - pByte++; - } - - // Fill comparer with value byte for comparisons - // - // comparer = 0/0/value/value - uint comparer = (((uint)value << 8) + (uint)value); - // comparer = value/value/value/value - comparer = (comparer << 16) + comparer; - - // Run through buffer until we hit a 4-byte section which contains - // the byte we're looking for or until we exhaust the buffer. - while (count > 3) - { - // Test the buffer for presence of value. comparer contains the byte - // replicated 4 times. - uint t1 = *(uint*)pByte; - t1 = t1 ^ comparer; - uint t2 = 0x7efefeff + t1; - t1 = t1 ^ 0xffffffff; - t1 = t1 ^ t2; - t1 = t1 & 0x81010100; - - // if t1 is zero then these 4-bytes don't contain a match - if (t1 != 0) - { - // We've found a match for value, figure out which position it's in. - int foundIndex = (int)(pByte - src); - if (pByte[0] == value) - return foundIndex; - else if (pByte[1] == value) - return foundIndex + 1; - else if (pByte[2] == value) - return foundIndex + 2; - else if (pByte[3] == value) - return foundIndex + 3; - } - - count -= 4; - pByte += 4; - } - - // Catch any bytes that might be left at the tail of the buffer - while (count > 0) - { - if (*pByte == value) - return (int)(pByte - src); - - count--; - pByte++; - } - - // If we don't have a match return -1; - return -1; - } - - internal static unsafe void ZeroMemory(byte* src, long len) - { - while (len-- > 0) - *(src + len) = 0; - } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] - internal static unsafe void memcpy(byte* src, int srcIndex, byte[] dest, int destIndex, int len) - { - BCLDebug.Assert((srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!"); - BCLDebug.Assert(dest.Length - destIndex >= len, "not enough bytes in dest"); - // If dest has 0 elements, the fixed statement will throw an - // IndexOutOfRangeException. Special-case 0-byte copies. - if (len == 0) - return; - fixed (byte* pDest = dest) - { - memcpyimpl(src + srcIndex, pDest + destIndex, len); - } - } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] - internal static unsafe void memcpy(byte[] src, int srcIndex, byte* pDest, int destIndex, int len) - { - BCLDebug.Assert((srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!"); - BCLDebug.Assert(src.Length - srcIndex >= len, "not enough bytes in src"); - // If dest has 0 elements, the fixed statement will throw an - // IndexOutOfRangeException. Special-case 0-byte copies. - if (len == 0) - return; - fixed (byte* pSrc = src) - { - memcpyimpl(pSrc + srcIndex, pDest + destIndex, len); - } - } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] - internal static unsafe void memcpy(char* pSrc, int srcIndex, char* pDest, int destIndex, int len) - { - BCLDebug.Assert((srcIndex >= 0) && (destIndex >= 0) && (len >= 0), "Index and length must be non-negative!"); - - // No boundary check for buffer overruns - dangerous - if (len == 0) - return; - memcpyimpl((byte*)(char*)(pSrc + srcIndex), (byte*)(char*)(pDest + destIndex), len * 2); - } - - // Note - using a long instead of an int for the length parameter - // slows this method down by ~18%. - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] - internal static unsafe void memcpyimpl(byte* src, byte* dest, int len) - { - BCLDebug.Assert(len >= 0, "Negative length in memcopy!"); - - // It turns out that on AMD64 it is faster to not be careful of alignment issues. - // On IA64 it is necessary to be careful... Oh well. When we do the IA64 push we - // can work on this implementation. -#if IA64 - long dstAlign = 8 - (((long)dest) & 7); // number of bytes to copy before dest is 8-byte aligned - - while ((dstAlign > 0) && (len > 0)) - { - *dest++ = *src++; - - len--; - dstAlign--; - } - - long srcAlign = 8 - (((long)src) & 7); - - if (len > 0) - { - if (srcAlign != 8) - { - if (4 == srcAlign) - { - while (len >= 4) - { - ((int*)dest)[0] = ((int*)src)[0]; - dest += 4; - src += 4; - len -= 4; - } - - srcAlign = 2; // fall through to 2-byte copies - } - - if ((2 == srcAlign) || (6 == srcAlign)) - { - while (len >= 2) - { - ((short*)dest)[0] = ((short*)src)[0]; - dest += 2; - src += 2; - len -= 2; - } - } - - while (len-- > 0) - { - *dest++ = *src++; - } - } - else - { - if (len >= 16) - { - do - { - ((long*)dest)[0] = ((long*)src)[0]; - ((long*)dest)[1] = ((long*)src)[1]; - dest += 16; - src += 16; - } while ((len -= 16) >= 16); - } - if (len > 0) // protection against negative len and optimization for len==16*N - { - if ((len & 8) != 0) - { - ((long*)dest)[0] = ((long*)src)[0]; - dest += 8; - src += 8; - } - if ((len & 4) != 0) - { - ((int*)dest)[0] = ((int*)src)[0]; - dest += 4; - src += 4; - } - if ((len & 2) != 0) - { - ((short*)dest)[0] = ((short*)src)[0]; - dest += 2; - src += 2; - } - if ((len & 1) != 0) - { - *dest++ = *src++; - } - } - } - } - -#else - // AMD64 implementation uses longs instead of ints where possible - // - // This is a faster memcpy implementation, from - // COMString.cpp. For our strings, this beat the processor's - // repeat & move single byte instruction, which memcpy expands into. - // (You read that correctly.) - // This is 3x faster than a simple while loop copying byte by byte, - // for large copies. - if (len >= 16) - { - do - { -#if AMD64 - ((long*)dest)[0] = ((long*)src)[0]; - ((long*)dest)[1] = ((long*)src)[1]; -#else - ((int*)dest)[0] = ((int*)src)[0]; - ((int*)dest)[1] = ((int*)src)[1]; - ((int*)dest)[2] = ((int*)src)[2]; - ((int*)dest)[3] = ((int*)src)[3]; -#endif - dest += 16; - src += 16; - } while ((len -= 16) >= 16); - } - if (len > 0) // protection against negative len and optimization for len==16*N - { - if ((len & 8) != 0) - { -#if AMD64 - ((long*)dest)[0] = ((long*)src)[0]; -#else - ((int*)dest)[0] = ((int*)src)[0]; - ((int*)dest)[1] = ((int*)src)[1]; -#endif - dest += 8; - src += 8; - } - if ((len & 4) != 0) - { - ((int*)dest)[0] = ((int*)src)[0]; - dest += 4; - src += 4; - } - if ((len & 2) != 0) - { - ((short*)dest)[0] = ((short*)src)[0]; - dest += 2; - src += 2; - } - if ((len & 1) != 0) - *dest++ = *src++; - } - -#endif // IA64 - } - } -} diff --git a/src/System.Management.Automation/namespaces/ProviderBase.cs b/src/System.Management.Automation/namespaces/ProviderBase.cs index 73feb852585..4d406a82717 100644 --- a/src/System.Management.Automation/namespaces/ProviderBase.cs +++ b/src/System.Management.Automation/namespaces/ProviderBase.cs @@ -495,483 +495,6 @@ internal object ClearPropertyDynamicParameters( #endregion IPropertyCmdletProvider -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - #region IMultivaluePropertyCmdletProvider - - /// - /// Internal wrapper for the GetPropertyAt protected method. This method will - /// only be called if the provider implements the IPropertyCmdletProvider interface. - /// - /// - /// - /// The path to the item to retrieve property from. - /// - /// - /// - /// The property that should be retrieved. - /// - /// - /// - /// The index of the value to be retrieved from the property. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - internal void GetPropertyValueAt( - string path, - string propertyName, - object index, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = - this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - throw - providerBaseTracer.NewNotSupportedException( - "SessionStateStrings", - "IMultivaluePropertyCmdletProvider_NotSupported"); - } - - // Call interface method - - propertyProvider.GetPropertyValueAt(path, propertyName, index); - } // GetPropertyValueAt - - /// - /// Gives the provider a chance to attach additional parameters to - /// the get-propertyvalue -at cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The property that should be retrieved. - /// - /// - /// - /// The index of the value to be retrieved from the property. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - internal object GetPropertyValueAtDynamicParameters( - string path, - string propertyName, - object at, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - return null; - } - return propertyProvider.GetPropertyValueAtDynamicParameters(path, propertyName, at); - } // GetPropertyValueAtDynamicParameters - - /// - /// Sets the specified properties of the item at the specified path at the specified - /// position if the property is a multivalued property. - /// - /// - /// - /// The path to the item to set the properties on. - /// - /// - /// - /// The position to place the new value of the property. - /// - /// - /// - /// A PSObject which contains a collection of the name, type, value - /// of the properties to be set. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// Nothing. An instance of PSObject representing the properties that were set - /// should be passed to the WriteObject() method. - /// - /// - internal void SetPropertyValueAt( - string path, - object position, - PSObject propertyValue, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = - this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - throw - providerBaseTracer.NewNotSupportedException( - "SessionStateStrings", - "IMultivaluePropertyCmdletProvider_NotSupported"); - } - - // Call interface method - - propertyProvider.SetPropertyValueAt(path, position, propertyValue); - } // SetPropertyValueAt - - /// - /// Gives the provider a chance to attach additional parameters to - /// the set-propertyvalue -at cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The position to place the new value of the property. - /// - /// - /// - /// A PSObject which contains a collection of the name, type, value - /// of the properties to be added. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - internal object SetPropertyValueAtDynamicParameters( - string path, - object at, - PSObject propertyValue, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - return null; - } - return propertyProvider.SetPropertyValueAtDynamicParameters(path, at, propertyValue); - } // SetPropertyValueAtDynamicParameters - - /// - /// Internal wrapper for the ClearPropertyAt protected method. This method will - /// only be called if the provider implements the - /// IMultivaluePropertyCmdletProvider interface. - /// - /// - /// - /// The path to the item from which the property should be cleared. - /// - /// - /// - /// The name of the property that should be cleared. - /// - /// - /// - /// The position of the value of the property to be cleared. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows dynamic clearing of properties. - /// - /// - internal void ClearPropertyValueAt( - string path, - string propertyName, - object at, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = - this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - throw - providerBaseTracer.NewNotSupportedException( - "SessionStateStrings", - "IMultivaluePropertyCmdletProvider_NotSupported"); - } - - // Call interface method - - propertyProvider.ClearPropertyValueAt(path, propertyName, at); - } // ClearPropertyValueAt - - /// - /// Gives the provider a chance to attach additional parameters to - /// the clear-propertyvalue -at cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The name of the property that should be cleared. - /// - /// - /// - /// The position of the value of the property to be cleared. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - internal object ClearPropertyValueAtDynamicParameters( - string path, - string propertyName, - object at, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - return null; - } - return propertyProvider.ClearPropertyValueAtDynamicParameters(path, propertyName, at); - } // ClearPropertyValueAtDynamicParameters - - /// - /// Internal wrapper for the RemovePropertyValueAt protected method. This method will - /// only be called if the provider implements the - /// IMultivaluePropertyCmdletProvider interface. - /// - /// - /// - /// The path to the item from which the property value should be removed. - /// - /// - /// - /// The name of the property that the value should be remove from. - /// - /// - /// - /// The position of the value of the property to be removed. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows dynamic removing of property values. - /// - /// - internal void RemovePropertyValueAt( - string path, - string propertyName, - object at, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = - this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - throw - providerBaseTracer.NewNotSupportedException( - "SessionStateStrings", - "IMultivaluePropertyCmdletProvider_NotSupported"); - } - - // Call interface method - - propertyProvider.RemovePropertyValueAt(path, propertyName, at); - } // RemovePropertyValueAt - - /// - /// Gives the provider a chance to attach additional parameters to - /// the remove-propertyvalue -at cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The name of the property that the value should be remove from. - /// - /// - /// - /// The position of the value of the property to be removed. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - internal object RemovePropertyValueAtDynamicParameters( - string path, - string propertyName, - object at, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - return null; - } - return propertyProvider.RemovePropertyValueAtDynamicParameters(path, propertyName, at); - } // RemovePropertyValueAtDynamicParameters - - /// - /// Adds the specified properties of the item at the specified path at the specified - /// position if the property is a multivalued property. - /// - /// - /// - /// The path to the item to add the property to. - /// - /// - /// - /// The position to place the new value of the property. - /// - /// - /// - /// A PSObject which contains a collection of the name, type, value - /// of the properties to be added. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// Nothing. An instance of PSObject representing the properties that were set - /// should be passed to the WriteObject() method. - /// - /// - internal void AddPropertyValueAt( - string path, - object position, - PSObject propertyValue, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = - this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - throw - providerBaseTracer.NewNotSupportedException( - "SessionStateStrings", - "IMultivaluePropertyCmdletProvider_NotSupported"); - } - - // Call interface method - - propertyProvider.AddPropertyValueAt(path, position, propertyValue); - } // AddPropertyValueAt - - /// - /// Gives the provider a chance to attach additional parameters to - /// the add-propertyvalue -at cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The position to place the new value of the property. - /// - /// - /// - /// A PSObject which contains a collection of the name, type, value - /// of the properties to be added. - /// - /// - /// - /// The context under which this method is being called. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - internal object AddPropertyValueAtDynamicParameters( - string path, - object at, - PSObject propertyValue, - CmdletProviderContext cmdletProviderContext) - { - Context = cmdletProviderContext; - - IMultivaluePropertyCmdletProvider propertyProvider = this as IMultivaluePropertyCmdletProvider; - - if (propertyProvider == null) - { - return null; - } - return propertyProvider.AddPropertyValueAtDynamicParameters(path, at, propertyValue); - } // AddPropertyValueAtDynamicParameters - - #endregion IMultivaluePropertyCmdletProvider -#endif // SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - #region IDynamicPropertyCmdletProvider /// @@ -2354,58 +1877,6 @@ private void WriteObject( Context.WriteObject(result); } // WriteObject -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - - /// - /// Converts the incoming object to a PSObject and then adds extra - /// data as notes. Then it writes the shell object to the context. - /// - /// - /// - /// The value of the property being written out. - /// - /// - /// - /// The path of the item being written out. - /// - /// - /// - /// The name of the property the value came from. - /// - /// - /// - /// The position in the property they value came from. - /// - /// - private void WriteObject( - object item, - string path, - string propertyName, - object position) - { - - PSObject result = WrapOutputInPSObject(item, path); - - // Now add the property - - PSNoteProperty propertyToAdd = new PSNoteProperty("PSProperty", propertyName); - result.Properties.Add(propertyToAdd); - providerBaseTracer.WriteLine("Attaching {0} = {1}", "PSProperty", propertyName); - - // Now add the position - - propertyToAdd = new PSNoteProperty("MshAt", position); - result.Properties.Add(propertyToAdd); - providerBaseTracer.WriteLine("Attaching {0} = {1}", "MshAt", position); - - Diagnostics.Assert ( - Context != null, - "The context should always be set"); - - Context.WriteObject(result); - } // WriteObject -#endif // SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - /// /// Converts the incoming object to a PSObject and then adds extra /// data as notes. Then it writes the shell object to the context. @@ -2636,50 +2107,6 @@ public void WriteSecurityDescriptorObject( } } // WriteSecurityDescriptorObject -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - /// - /// Writes a property value object to the output as a PSObject with extra data attached - /// as notes. - /// - /// - /// - /// The value of the property to be written. - /// - /// - /// - /// The path of the item being written. - /// - /// - /// - /// The properties to be written. - /// - /// - /// - /// The position at which the property value was retrieved or written. - /// - /// - /// - /// If streaming is on and the writeObjectHandler was specified then the object - /// gets written to the writeObjectHandler. If streaming is on and the writeObjectHandler - /// was not specified and the command object was specified, the object gets written to - /// the WriteObject method of the command object. - /// If streaming is off the object gets written to an accumulator collection. The collection - /// of written object can be retrieved using the AccumulatedObjects method. - /// - /// - public void WritePropertyValueObject( - object item, - string path, - string propertyName, - object position) - { - using(PSTransactionManager.GetEngineProtectionScope()) - { - WriteObject(item, path, propertyName, position); - } - } // WritePropertyValueObject -#endif - /// public void WriteError(ErrorRecord errorRecord) { diff --git a/src/System.Management.Automation/namespaces/RegistryProvider.cs b/src/System.Management.Automation/namespaces/RegistryProvider.cs index 5f3177a03cd..90baabc6821 100644 --- a/src/System.Management.Automation/namespaces/RegistryProvider.cs +++ b/src/System.Management.Automation/namespaces/RegistryProvider.cs @@ -64,9 +64,6 @@ namespace Microsoft.PowerShell.Commands public sealed partial class RegistryProvider : NavigationCmdletProvider, IPropertyCmdletProvider, -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - IMultivaluePropertyCmdletProvider, -#endif IDynamicPropertyCmdletProvider, ISecurityDescriptorCmdletProvider { @@ -2133,830 +2130,6 @@ public object ClearPropertyDynamicParameters( #endregion IPropertyCmdletProvider -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - - #region IMultivaluePropertyCmdletProvider - - /// - /// Gets a value of a property from the item specified by the path. - /// - /// - /// - /// The path to the item from which the property value should be retrieved. - /// - /// - /// - /// The property to get the value from. - /// - /// - /// - /// The position of the property to get. - /// - /// - /// - /// Nothing. A PSObject representing the property and value that was - /// retrieved should be passed to the WriteObject() method. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows multivalued properties. - /// - /// - public void GetPropertyValueAt( - string path, - string propertyName, - object at) - { - if (path == null) - { - throw tracer.NewArgumentNullException("path"); - } - - if (!CheckOperationNotAllowedOnHiveContainer(path)) - { - return; - } - - IRegistryWrapper key = GetRegkeyForPathWriteIfError(path, false); - - if (key == null) - { - return; - } - - // Convert the at parameter to an int - int index = GetIndexFromAt(at); - - if (index == -1) - { - // The key was not found, write out an error. - - ArgumentException exception = - new ArgumentException( - RegistryProviderStrings.BadAtParam; - WriteError (new ErrorRecord (exception, exception.GetType().FullName, ErrorCategory.InvalidArgument, path)); - - return; - } - - PSObject propertyResults = new PSObject(); - - try - { - string valueName = propertyName; - - // Need to convert the default value name to "(default)" - if (String.IsNullOrEmpty(valueName)) - { - valueName = GetLocalizedDefaultToken(); - } - object resultValue = key.GetValue(valueName); - - if (resultValue != null) - { - if (resultValue is IList && - at != null) - { - resultValue = ((IList)resultValue)[index]; - } - - propertyResults.Properties.Add(new PSNoteProperty(valueName, resultValue)); - - WritePropertyObject(propertyResults, path); - } - } - catch (System.IO.IOException ioException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (ioException, ioException.GetType().FullName, ErrorCategory.ReadError, path)); - - } - catch (System.Security.SecurityException securityException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (securityException, securityException.GetType().FullName, ErrorCategory.PermissionDenied, path)); - } - catch (System.UnauthorizedAccessException unauthorizedAccessException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (unauthorizedAccessException, unauthorizedAccessException.GetType().FullName, ErrorCategory.PermissionDenied, path)); - } - } // GetPropertyValueAt - - - - /// - /// Sets a property value on the item specified by the path. - /// - /// - /// - /// The path to the item on which the property should be set. - /// - /// - /// - /// The position of the property to set. - /// - /// - /// - /// The property to set the value on. - /// - /// - /// - /// Nothing. A PSObject representing the property and value that was - /// set should be passed to the WriteObject() method. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows multivalued properties. - /// - /// - public void SetPropertyValueAt( - string path, - object at, - PSObject propertyValue) - { - if (path == null) - { - throw tracer.NewArgumentNullException("path"); - } - - if (!CheckOperationNotAllowedOnHiveContainer(path)) - { - return; - } - - if (propertyValue == null) - { - throw tracer.NewArgumentNullException("propertyValue"); - } - - // Convert the at parameter to an int - int index = GetIndexFromAt(at); - - if (index == -1) - { - // The key was not found, write out an error. - - ArgumentException exception = - new ArgumentException( - RegistryProviderStrings.BadAtParam; - WriteError (new ErrorRecord (exception, exception.GetType().FullName, ErrorCategory.InvalidArgument, path)); - - return; - } - - IRegistryWrapper key = GetRegkeyForPathWriteIfError(path, true); - - if (key == null) - { - return; - } - - string action = - RegistryProviderStrings.SetPropertyValueAtAction; - - string resourceTemplate = - RegistryProviderStrings.SetPropertyValueAtResourceTemplate; - foreach (PSMemberInfo property in propertyValue.Properties) - { - try - { - object newPropertyValue = property.Value; - - string resource = - String.Format( - Host.CurrentCulture, - resourceTemplate, - path, - property.Name, - at); - - if (ShouldProcess(resource, action)) - { - string propertyNameToSet = GetPropertyName(property.Name); - - // First get the current value - - object currentValue = key.GetValue(propertyNameToSet); - - if (currentValue != null && - currentValue is IList) - { - ((IList)currentValue)[index] = newPropertyValue; - } - else - { - currentValue = newPropertyValue; - } - - key.SetValue(propertyNameToSet, currentValue); - - // Now write out the value by getting the value from the store - - object value = key.GetValue(propertyNameToSet); - - PSObject result = new PSObject(); - result.Properties.Add(new PSNoteProperty(property.Name, newPropertyValue)); - - WritePropertyObject(result, path); - } - } - catch (System.IO.IOException ioException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (ioException, ioException.GetType().FullName, ErrorCategory.WriteError, property.Name)); - continue; - } - catch (System.Security.SecurityException securityException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (securityException, securityException.GetType().FullName, ErrorCategory.PermissionDenied, property.Name)); - continue; - } - catch (System.UnauthorizedAccessException unauthorizedAccessException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (unauthorizedAccessException, unauthorizedAccessException.GetType().FullName, ErrorCategory.PermissionDenied, property.Name)); - continue; - } - - - } - } // SetPropertyValueAt - - - /// - /// Clears the specified value of a property on the item specified by the path. - /// - /// - /// - /// The path to the item from which the property value should be cleared. - /// - /// - /// - /// The property to clear the value from. - /// - /// - /// - /// The position of the property to clear. - /// - /// - /// - /// Nothing. A PSObject representing the property and value that was - /// retrieved should be passed to the WriteObject() method. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows multivalued properties. - /// - /// - public void ClearPropertyValueAt( - string path, - string propertyName, - object at) - { - throw tracer.NewNotImplementedException(); - } - - - /// - /// Removes the specified value of a property on the item specified by the path. - /// - /// - /// - /// The path to the item from which the property value should be removed. - /// - /// - /// - /// The property to remove the value from. - /// - /// - /// - /// The position of the property value to remove. - /// - /// - /// - /// Nothing. A PSObject representing the property and value that was - /// removed should be passed to the WriteObject() method. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows multivalued properties. - /// - /// - public void RemovePropertyValueAt( - string path, - string propertyName, - object at) - { - if (path == null) - { - throw tracer.NewArgumentNullException("path"); - } - - if (!CheckOperationNotAllowedOnHiveContainer(path)) - { - return; - } - - // Convert the at parameter to an int - int index = GetIndexFromAt(at); - - if (index == -1) - { - // The key was not found, write out an error. - - ArgumentException exception = - new ArgumentException( - RegistryProviderStrings.BadAtParam); - WriteError (new ErrorRecord (exception, exception.GetType().FullName, ErrorCategory.InvalidArgument, path)); - - return; - } - - IRegistryWrapper key = GetRegkeyForPathWriteIfError(path, true); - - if (key == null) - { - return; - } - - string action = RegistryProviderStrings.RemovePropertyValueAtAction; - - string resourceTemplate = RegistryProviderStrings.RemovePropertyValueAtResourceTemplate; - - string resource = - String.Format( - Host.CurrentCulture, - resourceTemplate, - path, - propertyName, - at); - - if (ShouldProcess(resource, action)) - { - try - { - string propertyNameToRemove = GetPropertyName(propertyName); - - // First get the current value - - object currentValue = key.GetValue(propertyNameToRemove); - - if (currentValue != null && - currentValue is string[]) - { - ArrayList newValueArrayList = new ArrayList((string[])currentValue); - newValueArrayList.RemoveAt(index); - currentValue = newValueArrayList.ToArray(typeof(string)); - } - else if (currentValue != null && - currentValue is byte[]) - { - ArrayList newValueArrayList = new ArrayList((byte[])currentValue); - newValueArrayList.RemoveAt(index); - currentValue = newValueArrayList.ToArray(typeof(byte)); - } - else - { - Exception e = - new ArgumentException ( - RegistryProviderStrings.PropertyNotMultivalued); - WriteError (new ErrorRecord ( - e, - e.GetType().FullName, - ErrorCategory.InvalidOperation, - propertyNameToRemove)); - return; - } - - key.SetValue(propertyNameToRemove, currentValue); - } - catch (System.IO.IOException ioException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (ioException, ioException.GetType().FullName, ErrorCategory.WriteError, propertyName)); - } - catch (System.Security.SecurityException securityException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (securityException, securityException.GetType().FullName, ErrorCategory.PermissionDenied, propertyName)); - } - catch (System.UnauthorizedAccessException unauthorizedAccessException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (unauthorizedAccessException, unauthorizedAccessException.GetType().FullName, ErrorCategory.PermissionDenied, propertyName)); - } - - } - } // RemovePropertyValueAt - - /// - /// Adds a property value on the item specified by the path. - /// - /// - /// - /// The path to the item on which the property should be added. - /// - /// - /// - /// The position of the property to add. - /// - /// - /// - /// The property to add the value on. - /// - /// - /// - /// Nothing. A PSObject representing the property and value that was - /// added should be passed to the WriteObject() method. - /// - /// - /// - /// Implement this method when you are providing access to a data store - /// that allows multivalued properties. - /// - /// - public void AddPropertyValueAt( - string path, - object at, - PSObject propertyValue) - { - if (path == null) - { - throw tracer.NewArgumentNullException("path"); - } - - if (!CheckOperationNotAllowedOnHiveContainer(path)) - { - return; - } - - if (propertyValue == null) - { - throw tracer.NewArgumentNullException("propertyValue"); - } - - // Convert the at parameter to an int - int index = GetIndexFromAt(at); - - IRegistryWrapper key = GetRegkeyForPathWriteIfError(path, true); - - if (key == null) - { - return; - } - - string action = RegistryProviderStrings.AddPropertyValueAtAction; - - string resourceTemplate = RegistryProviderStrings.AddPropertyValueAtResourceTemplate; - - PSMemberInfoCollection properties = null; - - try - { - properties = propertyValue.Properties; - } - catch (System.IO.IOException ioException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (ioException, ioException.GetType().FullName, ErrorCategory.ReadError, path)); - return; - } - catch (System.Security.SecurityException securityException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (securityException, securityException.GetType().FullName, ErrorCategory.PermissionDenied, path)); - return; - } - catch (System.UnauthorizedAccessException unauthorizedAccessException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (unauthorizedAccessException, unauthorizedAccessException.GetType().FullName, ErrorCategory.PermissionDenied, path)); - return; - } - - - foreach (PSMemberInfo property in properties) - { - object newPropertyValue = property.Value; - - string resource = - String.Format( - Host.CurrentCulture, - resourceTemplate, - path, - property.Name, - at); - - if (ShouldProcess(resource, action)) - { - string propertyNameToSet = GetPropertyName(property.Name); - - // First get the current value - - object currentValue = null; - - try - { - currentValue = key.GetValue(propertyNameToSet); - } - catch (System.IO.IOException ioException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (ioException, ioException.GetType().FullName, ErrorCategory.ReadError, property.Name)); - continue; - } - catch (System.Security.SecurityException securityException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (securityException, securityException.GetType().FullName, ErrorCategory.PermissionDenied, property.Name)); - continue; - } - catch (System.UnauthorizedAccessException unauthorizedAccessException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (unauthorizedAccessException, unauthorizedAccessException.GetType().FullName, ErrorCategory.PermissionDenied, property.Name)); - continue; - } - - if (currentValue != null && - currentValue is string[]) - { - ArrayList newValueArrayList = new ArrayList((string[])currentValue); - - if (index == -1 || index >= newValueArrayList.Count) - { - newValueArrayList.Add(newPropertyValue.ToString()); - } - else - { - newValueArrayList.Insert(index, newPropertyValue.ToString()); - } - currentValue = newValueArrayList.ToArray(typeof(string)); - } - else if (currentValue != null && currentValue is byte[]) - { - ArrayList newValueArrayList = new ArrayList((byte[])currentValue); - - if (index == -1 || index >= newValueArrayList.Count) - { - newValueArrayList.Add((byte)newPropertyValue); - } - else - { - newValueArrayList.Insert(index, (byte)newPropertyValue); - } - currentValue = newValueArrayList.ToArray(typeof(byte)); - } - else - { - Exception e = - new ArgumentException ( - RegistryProviderStrings.PropertyNotMultivaluedChange); - WriteError (new ErrorRecord ( - e, - e.GetType().FullName, - ErrorCategory.InvalidOperation, - propertyNameToSet)); - continue; - } - - try - { - key.SetValue(propertyNameToSet, currentValue); - - // Now write out the value by getting the value from the store - - object value = key.GetValue(propertyNameToSet); - - PSObject result = new PSObject(); - result.Properties.Add(new PSNoteProperty(property.Name, value)); - - WritePropertyObject(result, path); - } - catch (System.IO.IOException ioException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (ioException, ioException.GetType().FullName, ErrorCategory.WriteError, property.Name)); - } - catch (System.Security.SecurityException securityException) - { - // An exception occurred while trying to set the value. Write - // out the error. - - WriteError (new ErrorRecord (securityException, securityException.GetType().FullName, ErrorCategory.PermissionDenied, property.Name)); - } - catch (System.UnauthorizedAccessException unauthorizedAccessException) - { - // An exception occurred while trying to get the key. Write - // out the error. - - WriteError (new ErrorRecord (unauthorizedAccessException, unauthorizedAccessException.GetType().FullName, ErrorCategory.PermissionDenied, property.Name)); - } - } // if ShouldProcess - } - } // RemovePropertyValueAt - - #region Unimplemented methods - - /// - /// Gives the provider a chance to attach additional parameters to the - /// get-propertyvalue cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The property to get the value from. - /// - /// - /// - /// The position of the property to get. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - public object GetPropertyValueAtDynamicParameters( - string path, - string propertyName, - object at) - { - return null; - } - - /// - /// Gives the provider a chance to attach additional parameters to the - /// set-propertyvalue cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The position of the property to get. - /// - /// - /// - /// The property to set the value on. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - public object SetPropertyValueAtDynamicParameters( - string path, - object at, - PSObject propertyValue) - { - return null; - } - - - /// - /// Gives the provider a chance to attach additional parameters to the - /// clear-propertyvalue cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The property to clear the value from. - /// - /// - /// - /// The position of the property to clear. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - public object ClearPropertyValueAtDynamicParameters( - string path, - string propertyName, - object at) - { - return null; - } - - /// - /// Gives the provider a chance to attach additional parameters to the - /// remove-propertyvalue cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The property to remove the value from. - /// - /// - /// - /// The position of the property to remove. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - public object RemovePropertyValueAtDynamicParameters( - string path, - string propertyName, - object at) - { - return null; - } - - /// - /// Gives the provider a chance to attach additional parameters to the - /// add-propertyvalue cmdlet. - /// - /// - /// - /// If the path was specified on the command line, this is the path - /// to the item to get the dynamic parameters for. - /// - /// - /// - /// The position of the property to add. - /// - /// - /// - /// The property to add the value on. - /// - /// - /// - /// An object that has properties and fields decorated with - /// parsing attributes similar to a cmdlet class. - /// - /// - public object AddPropertyValueAtDynamicParameters( - string path, - object at, - PSObject propertyValue) - { - return null; - } - - #endregion Unimplemented method - - #endregion IMultivaluePropertyCmdletProvider -#endif // SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - #region IDynamicPropertyCmdletProvider /// diff --git a/src/System.Management.Automation/namespaces/RegistrySecurity.cs b/src/System.Management.Automation/namespaces/RegistrySecurity.cs index 9faf553ac57..cf7674be4ba 100644 --- a/src/System.Management.Automation/namespaces/RegistrySecurity.cs +++ b/src/System.Management.Automation/namespaces/RegistrySecurity.cs @@ -22,9 +22,6 @@ namespace Microsoft.PowerShell.Commands public sealed partial class RegistryProvider : NavigationCmdletProvider, IPropertyCmdletProvider, -#if SUPPORTS_IMULTIVALUEPROPERTYCMDLETPROVIDER - IMultivaluePropertyCmdletProvider, -#endif IDynamicPropertyCmdletProvider, ISecurityDescriptorCmdletProvider {