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 static void AddNoteProperty <T>( PSObject pso, string propertyName, RemotingEncoder.ValueGetterDelegate <T> valueGetter) { T obj = default(T); try { obj = valueGetter(); } catch (Exception ex) { CommandProcessorBase.CheckForSevereException(ex); RemotingEncoder.etwTracer.AnalyticChannel.WriteWarning(PSEventId.Serializer_PropertyGetterFailed, PSOpcode.Exception, PSTask.Serialization, (object)propertyName, valueGetter.Target == null ? (object)string.Empty : (object)valueGetter.Target.GetType().FullName, (object)ex.ToString(), ex.InnerException == null ? (object)string.Empty : (object)ex.InnerException.ToString()); } pso.Properties.Add((PSPropertyInfo) new PSNoteProperty(propertyName, (object)obj)); }
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); } }