/// <summary> /// Adds the information about this informational record to a PSObject as note properties. /// The PSObject is used to serialize the record during remote operations. /// </summary> /// <remarks> /// InvocationInfos are usually serialized as part of another object, so we add "InvocationInfo_" to /// the note properties to prevent collisions with any properties set by the containing object. /// </remarks> internal void ToPSObjectForRemoting(PSObject psObject) { RemotingEncoder.AddNoteProperty <object>(psObject, "InvocationInfo_BoundParameters", () => this.BoundParameters); RemotingEncoder.AddNoteProperty <CommandOrigin>(psObject, "InvocationInfo_CommandOrigin", () => this.CommandOrigin); RemotingEncoder.AddNoteProperty <bool>(psObject, "InvocationInfo_ExpectingInput", () => this.ExpectingInput); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_InvocationName", () => this.InvocationName); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_Line", () => this.Line); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_OffsetInLine", () => this.OffsetInLine); RemotingEncoder.AddNoteProperty <long>(psObject, "InvocationInfo_HistoryId", () => this.HistoryId); RemotingEncoder.AddNoteProperty <int[]>(psObject, "InvocationInfo_PipelineIterationInfo", () => this.PipelineIterationInfo); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_PipelineLength", () => this.PipelineLength); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_PipelinePosition", () => this.PipelinePosition); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_PSScriptRoot", () => this.PSScriptRoot); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_PSCommandPath", () => this.PSCommandPath); // PositionMessage is ignored when deserializing because it is synthesized from the other position related fields, but // it is serialized for backwards compatibility. RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_PositionMessage", () => this.PositionMessage); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_ScriptLineNumber", () => this.ScriptLineNumber); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_ScriptName", () => this.ScriptName); RemotingEncoder.AddNoteProperty <object>(psObject, "InvocationInfo_UnboundArguments", () => this.UnboundArguments); ScriptExtent extent = DisplayScriptPosition as ScriptExtent; if (extent != null) { extent.ToPSObjectForRemoting(psObject); RemotingEncoder.AddNoteProperty(psObject, "SerializeExtent", () => true); } else { RemotingEncoder.AddNoteProperty(psObject, "SerializeExtent", () => false); } RemoteCommandInfo.ToPSObjectForRemoting(this.MyCommand, psObject); }
internal static void ToPSObjectForRemoting(CommandInfo commandInfo, PSObject psObject) { RemotingEncoder.ValueGetterDelegate <CommandTypes> valueGetter = null; RemotingEncoder.ValueGetterDelegate <string> delegate3 = null; RemotingEncoder.ValueGetterDelegate <string> delegate4 = null; RemotingEncoder.ValueGetterDelegate <SessionStateEntryVisibility> delegate5 = null; if (commandInfo != null) { if (valueGetter == null) { valueGetter = () => commandInfo.CommandType; } RemotingEncoder.AddNoteProperty <CommandTypes>(psObject, "CommandInfo_CommandType", valueGetter); if (delegate3 == null) { delegate3 = () => commandInfo.Definition; } RemotingEncoder.AddNoteProperty <string>(psObject, "CommandInfo_Definition", delegate3); if (delegate4 == null) { delegate4 = () => commandInfo.Name; } RemotingEncoder.AddNoteProperty <string>(psObject, "CommandInfo_Name", delegate4); if (delegate5 == null) { delegate5 = () => commandInfo.Visibility; } RemotingEncoder.AddNoteProperty <SessionStateEntryVisibility>(psObject, "CommandInfo_Visibility", delegate5); } }
internal void ToPSObjectForRemoting(PSObject dest) { RemotingEncoder.AddNoteProperty <Exception>(dest, "Exception", (RemotingEncoder.ValueGetterDelegate <Exception>)(() => this.Exception)); RemotingEncoder.AddNoteProperty <object>(dest, "TargetObject", (RemotingEncoder.ValueGetterDelegate <object>)(() => this.TargetObject)); RemotingEncoder.AddNoteProperty <string>(dest, "FullyQualifiedErrorId", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.FullyQualifiedErrorId)); RemotingEncoder.AddNoteProperty <InvocationInfo>(dest, "InvocationInfo", (RemotingEncoder.ValueGetterDelegate <InvocationInfo>)(() => this.InvocationInfo)); RemotingEncoder.AddNoteProperty <int>(dest, "ErrorCategory_Category", (RemotingEncoder.ValueGetterDelegate <int>)(() => (int)this.CategoryInfo.Category)); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_Activity", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.CategoryInfo.Activity)); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_Reason", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.CategoryInfo.Reason)); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_TargetName", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.CategoryInfo.TargetName)); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_TargetType", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.CategoryInfo.TargetType)); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_Message", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.CategoryInfo.GetMessage(CultureInfo.CurrentCulture))); if (this.ErrorDetails != null) { RemotingEncoder.AddNoteProperty <string>(dest, "ErrorDetails_Message", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.ErrorDetails.Message)); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorDetails_RecommendedAction", (RemotingEncoder.ValueGetterDelegate <string>)(() => this.ErrorDetails.RecommendedAction)); } if (!this.SerializeExtendedInfo || this.InvocationInfo == null) { SerializationUtilities.AddProperty(dest, "SerializeExtendedInfo", (object)false); } else { SerializationUtilities.AddProperty(dest, "SerializeExtendedInfo", (object)true); this.InvocationInfo.ToPSObjectForRemoting(dest); RemotingEncoder.AddNoteProperty <object>(dest, "PipelineIterationInfo", (RemotingEncoder.ValueGetterDelegate <object>)(() => (object)this.PipelineIterationInfo)); } }
internal void ToPSObjectForRemoting(PSObject psObject) { RemotingEncoder.AddNoteProperty <object>(psObject, "InvocationInfo_BoundParameters", () => this.BoundParameters); RemotingEncoder.AddNoteProperty <System.Management.Automation.CommandOrigin>(psObject, "InvocationInfo_CommandOrigin", () => this.CommandOrigin); RemotingEncoder.AddNoteProperty <bool>(psObject, "InvocationInfo_ExpectingInput", () => this.ExpectingInput); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_InvocationName", () => this.InvocationName); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_Line", () => this.Line); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_OffsetInLine", () => this.OffsetInLine); RemotingEncoder.AddNoteProperty <long>(psObject, "InvocationInfo_HistoryId", () => this.HistoryId); RemotingEncoder.AddNoteProperty <int[]>(psObject, "InvocationInfo_PipelineIterationInfo", () => this.PipelineIterationInfo); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_PipelineLength", () => this.PipelineLength); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_PipelinePosition", () => this.PipelinePosition); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_PSScriptRoot", () => this.PSScriptRoot); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_PSCommandPath", () => this.PSCommandPath); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_PositionMessage", () => this.PositionMessage); RemotingEncoder.AddNoteProperty <int>(psObject, "InvocationInfo_ScriptLineNumber", () => this.ScriptLineNumber); RemotingEncoder.AddNoteProperty <string>(psObject, "InvocationInfo_ScriptName", () => this.ScriptName); RemotingEncoder.AddNoteProperty <object>(psObject, "InvocationInfo_UnboundArguments", () => this.UnboundArguments); ScriptExtent displayScriptPosition = this.DisplayScriptPosition as ScriptExtent; if (displayScriptPosition != null) { displayScriptPosition.ToPSObjectForRemoting(psObject); RemotingEncoder.AddNoteProperty <bool>(psObject, "SerializeExtent", () => true); } else { RemotingEncoder.AddNoteProperty <bool>(psObject, "SerializeExtent", () => false); } RemoteCommandInfo.ToPSObjectForRemoting(this.MyCommand, psObject); }
/// <summary> /// Adds the information about this instance to a PSObject as note properties. /// The PSObject is used to serialize the CommandInfo during remote operations. /// </summary> /// <remarks> /// CommandInfos are usually serialized as part of InvocationInfos, so we add "CommandInfo_" to /// the note properties to prevent collisions with any properties set by the containing object. /// </remarks> internal static void ToPSObjectForRemoting(CommandInfo commandInfo, PSObject psObject) { if (commandInfo != null) { RemotingEncoder.AddNoteProperty <CommandTypes>(psObject, "CommandInfo_CommandType", () => commandInfo.CommandType); RemotingEncoder.AddNoteProperty <string>(psObject, "CommandInfo_Definition", () => commandInfo.Definition); RemotingEncoder.AddNoteProperty <string>(psObject, "CommandInfo_Name", () => commandInfo.Name); RemotingEncoder.AddNoteProperty <SessionStateEntryVisibility>(psObject, "CommandInfo_Visibility", () => commandInfo.Visibility); } }
internal static void ToPSObjectForRemoting(CommandInfo commandInfo, PSObject psObject) { if (commandInfo == null) { return; } RemotingEncoder.AddNoteProperty <CommandTypes>(psObject, "CommandInfo_CommandType", (RemotingEncoder.ValueGetterDelegate <CommandTypes>)(() => commandInfo.CommandType)); RemotingEncoder.AddNoteProperty <string>(psObject, "CommandInfo_Definition", (RemotingEncoder.ValueGetterDelegate <string>)(() => commandInfo.Definition)); RemotingEncoder.AddNoteProperty <string>(psObject, "CommandInfo_Name", (RemotingEncoder.ValueGetterDelegate <string>)(() => commandInfo.Name)); RemotingEncoder.AddNoteProperty <SessionStateEntryVisibility>(psObject, "CommandInfo_Visibility", (RemotingEncoder.ValueGetterDelegate <SessionStateEntryVisibility>)(() => commandInfo.Visibility)); }
/// <summary> /// Adds the information about this informational record to a PSObject as note properties. /// The PSObject is used to serialize the record during remote operations. /// </summary> internal virtual void ToPSObjectForRemoting(PSObject psObject) { RemotingEncoder.AddNoteProperty <string>(psObject, "InformationalRecord_Message", () => this.Message); // // The invocation info may be null if the record was created via WriteVerbose/Warning/DebugLine instead of WriteVerbose/Warning/Debug, in that case // we set InformationalRecord_SerializeInvocationInfo to false. // if (!this.SerializeExtendedInfo || _invocationInfo == null) { RemotingEncoder.AddNoteProperty(psObject, "InformationalRecord_SerializeInvocationInfo", () => false); } else { RemotingEncoder.AddNoteProperty(psObject, "InformationalRecord_SerializeInvocationInfo", () => true); _invocationInfo.ToPSObjectForRemoting(psObject); RemotingEncoder.AddNoteProperty <object>(psObject, "InformationalRecord_PipelineIterationInfo", () => this.PipelineIterationInfo); } }
private void ToPSObjectForRemoting(PSObject dest, bool serializeExtInfo) { RemotingEncoder.ValueGetterDelegate <string> valueGetter = null; RemotingEncoder.ValueGetterDelegate <string> delegate3 = null; RemotingEncoder.ValueGetterDelegate <object> delegate4 = null; RemotingEncoder.AddNoteProperty <System.Exception>(dest, "Exception", () => this.Exception); RemotingEncoder.AddNoteProperty <object>(dest, "TargetObject", () => this.TargetObject); RemotingEncoder.AddNoteProperty <string>(dest, "FullyQualifiedErrorId", () => this.FullyQualifiedErrorId); RemotingEncoder.AddNoteProperty <System.Management.Automation.InvocationInfo>(dest, "InvocationInfo", () => this.InvocationInfo); RemotingEncoder.AddNoteProperty <int>(dest, "ErrorCategory_Category", () => (int)this.CategoryInfo.Category); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_Activity", () => this.CategoryInfo.Activity); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_Reason", () => this.CategoryInfo.Reason); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_TargetName", () => this.CategoryInfo.TargetName); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_TargetType", () => this.CategoryInfo.TargetType); RemotingEncoder.AddNoteProperty <string>(dest, "ErrorCategory_Message", () => this.CategoryInfo.GetMessage(CultureInfo.CurrentCulture)); if (this.ErrorDetails != null) { if (valueGetter == null) { valueGetter = () => this.ErrorDetails.Message; } RemotingEncoder.AddNoteProperty <string>(dest, "ErrorDetails_Message", valueGetter); if (delegate3 == null) { delegate3 = () => this.ErrorDetails.RecommendedAction; } RemotingEncoder.AddNoteProperty <string>(dest, "ErrorDetails_RecommendedAction", delegate3); } if (!serializeExtInfo || (this.InvocationInfo == null)) { RemotingEncoder.AddNoteProperty <bool>(dest, "SerializeExtendedInfo", () => false); } else { RemotingEncoder.AddNoteProperty <bool>(dest, "SerializeExtendedInfo", () => true); this.InvocationInfo.ToPSObjectForRemoting(dest); if (delegate4 == null) { delegate4 = () => this.PipelineIterationInfo; } RemotingEncoder.AddNoteProperty <object>(dest, "PipelineIterationInfo", delegate4); } }
internal virtual void ToPSObjectForRemoting(PSObject psObject) { RemotingEncoder.ValueGetterDelegate <object> valueGetter = null; RemotingEncoder.AddNoteProperty <string>(psObject, "InformationalRecord_Message", () => this.Message); if (!this.SerializeExtendedInfo || (this.invocationInfo == null)) { RemotingEncoder.AddNoteProperty <bool>(psObject, "InformationalRecord_SerializeInvocationInfo", () => false); } else { RemotingEncoder.AddNoteProperty <bool>(psObject, "InformationalRecord_SerializeInvocationInfo", () => true); this.invocationInfo.ToPSObjectForRemoting(psObject); if (valueGetter == null) { valueGetter = () => this.PipelineIterationInfo; } RemotingEncoder.AddNoteProperty <object>(psObject, "InformationalRecord_PipelineIterationInfo", valueGetter); } }