/// <summary> /// Determines whether the specified PropertyInstanceData is equal to the current PropertyInstanceData. /// </summary> /// <param name="that">The PropertyInstanceData to compare with the current object.</param> /// <returns>Returns true if the specified object has the same DefinitionName and the same values /// (using the PropertyInstanceValueData Equals method) as the current PropertyInstanceValueData; /// otherwise false.</returns> public virtual bool Equals(PropertyInstanceData that) { // if data is null - not equal if (ReferenceEquals(that, null)) { return(false); } // if data is has same reference to me - equal if (ReferenceEquals(this, that)) { return(true); } // otherwise do comparison logic here // First check it's the same definition name if (!DefinitionName.Equals(that.DefinitionName)) { return(false); } // Second, check it's the same number of values if (Values.Length != that.Values.Length) { return(false); } // Last check it's the same exact values return(!Values.Except(that.Values).Any()); }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (DefinitionName.Expression != null) { targetCommand.AddParameter("DefinitionName", DefinitionName.Get(context)); } if (DefinitionPath.Expression != null) { targetCommand.AddParameter("DefinitionPath", DefinitionPath.Get(context)); } if (Type.Expression != null) { targetCommand.AddParameter("Type", Type.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (ScriptBlock.Expression != null) { targetCommand.AddParameter("ScriptBlock", ScriptBlock.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (FilePath.Expression != null) { targetCommand.AddParameter("FilePath", FilePath.Get(context)); } if (LiteralPath.Expression != null) { targetCommand.AddParameter("LiteralPath", LiteralPath.Get(context)); } if (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if (InitializationScript.Expression != null) { targetCommand.AddParameter("InitializationScript", InitializationScript.Get(context)); } if (RunAs32.Expression != null) { targetCommand.AddParameter("RunAs32", RunAs32.Get(context)); } if (PSVersion.Expression != null) { targetCommand.AddParameter("PSVersion", PSVersion.Get(context)); } if (InputObject.Expression != null) { targetCommand.AddParameter("InputObject", InputObject.Get(context)); } if (ArgumentList.Expression != null) { targetCommand.AddParameter("ArgumentList", ArgumentList.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns> /// A hash code for the current <see cref="T:System.Object"/>. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { return(DefinitionName.GetHashCode()); }