private void DeserializeResultsInfo(SerializationInfo info) { ScheduledJob.ResultsInfo value = (ScheduledJob.ResultsInfo)info.GetValue("ResultsInfo", typeof(ScheduledJob.ResultsInfo)); this.CopyOutput(value.Output); this.CopyError(value.Error); this.CopyWarning(value.Warning); this.CopyVerbose(value.Verbose); this.CopyProgress(value.Progress); this.CopyDebug(value.Debug); }
private void SerializeResultsInfo(SerializationInfo info) { Collection <PSObject> pSObjects = new Collection <PSObject>(); Collection <ErrorRecord> errorRecords = new Collection <ErrorRecord>(); Collection <WarningRecord> warningRecords = new Collection <WarningRecord>(); Collection <VerboseRecord> verboseRecords = new Collection <VerboseRecord>(); Collection <ProgressRecord> progressRecords = new Collection <ProgressRecord>(); Collection <DebugRecord> debugRecords = new Collection <DebugRecord>(); if (this._job == null) { foreach (PSObject output in base.Output) { pSObjects.Add(new PSObject(output.BaseObject)); } foreach (ErrorRecord error in base.Error) { errorRecords.Add(error); } foreach (WarningRecord warning in base.Warning) { warningRecords.Add(warning); } foreach (VerboseRecord verbose in base.Verbose) { verboseRecords.Add(verbose); } foreach (ProgressRecord progress in base.Progress) { progressRecords.Add(progress); } foreach (DebugRecord debug in base.Debug) { debugRecords.Add(debug); } } else { if (base.JobStateInfo.Reason != null) { errorRecords.Add(new ErrorRecord(base.JobStateInfo.Reason, "ScheduledJobFailedState", ErrorCategory.InvalidResult, null)); } foreach (ErrorRecord errorRecord in this._job.Error) { errorRecords.Add(errorRecord); } foreach (Job job in this._job.ChildJobs) { if (job.JobStateInfo.Reason != null) { errorRecords.Add(new ErrorRecord(job.JobStateInfo.Reason, "ScheduledJobFailedState", ErrorCategory.InvalidResult, null)); } foreach (PSObject pSObject in job.Output) { pSObjects.Add(pSObject); } foreach (ErrorRecord error1 in job.Error) { errorRecords.Add(error1); } foreach (WarningRecord warningRecord in job.Warning) { warningRecords.Add(warningRecord); } foreach (VerboseRecord verboseRecord in job.Verbose) { verboseRecords.Add(verboseRecord); } foreach (ProgressRecord progressRecord in job.Progress) { progressRecords.Add(progressRecord); } IEnumerator <DebugRecord> enumerator = job.Debug.GetEnumerator(); using (enumerator) { while (enumerator.MoveNext()) { DebugRecord debugRecord = enumerator.Current; debugRecords.Add(debugRecord); } } } } ScheduledJob.ResultsInfo resultsInfo = new ScheduledJob.ResultsInfo(pSObjects, errorRecords, warningRecords, verboseRecords, progressRecords, debugRecords); info.AddValue("ResultsInfo", resultsInfo); }