コード例 #1
0
ファイル: PSActivity.cs プロジェクト: nickchal/pash
		private void PopulateSteamsData(PSResumableActivityContext arguments, NativeActivityContext context, HostParameterDefaults hostValues)
		{
			if (arguments.Streams.OutputStream != null)
			{
				if (base.Result.Expression == null)
				{
					if (hostValues.Parameters["Result"] != null && hostValues.Parameters["Result"].GetType() == typeof(PSDataCollection<PSObject>))
					{
						PSDataCollection<PSObject> item = hostValues.Parameters["Result"] as PSDataCollection<PSObject>;
						if (item != arguments.Streams.OutputStream && item != null && item.IsOpen)
						{
							foreach (PSObject outputStream in arguments.Streams.OutputStream)
							{
								item.Add(outputStream);
							}
						}
					}
				}
				else
				{
					base.Result.Set(context, arguments.Streams.OutputStream);
				}
			}
			if (arguments.Streams.InputStream != null)
			{
				if (base.Input.Expression == null)
				{
					if (hostValues.Parameters["Input"] != null && hostValues.Parameters["Input"].GetType() == typeof(PSDataCollection<PSObject>))
					{
						hostValues.Parameters["Input"] = arguments.Streams.InputStream;
					}
				}
				else
				{
					base.Input.Set(context, arguments.Streams.InputStream);
				}
			}
			if (arguments.Streams.ErrorStream != null)
			{
				if (this.PSError.Expression == null)
				{
					if (hostValues.Parameters["PSError"] != null && hostValues.Parameters["PSError"].GetType() == typeof(PSDataCollection<ErrorRecord>))
					{
						PSDataCollection<ErrorRecord> errorRecords = hostValues.Parameters["PSError"] as PSDataCollection<ErrorRecord>;
						if (errorRecords != arguments.Streams.ErrorStream && errorRecords != null && errorRecords.IsOpen)
						{
							foreach (ErrorRecord errorStream in arguments.Streams.ErrorStream)
							{
								errorRecords.Add(errorStream);
							}
						}
					}
				}
				else
				{
					this.PSError.Set(context, arguments.Streams.ErrorStream);
				}
			}
			if (arguments.Streams.WarningStream != null)
			{
				if (this.PSWarning.Expression == null)
				{
					if (hostValues.Parameters["PSWarning"] != null && hostValues.Parameters["PSWarning"].GetType() == typeof(PSDataCollection<WarningRecord>))
					{
						PSDataCollection<WarningRecord> warningRecords = hostValues.Parameters["PSWarning"] as PSDataCollection<WarningRecord>;
						if (warningRecords != arguments.Streams.WarningStream && warningRecords != null && warningRecords.IsOpen)
						{
							foreach (WarningRecord warningStream in arguments.Streams.WarningStream)
							{
								warningRecords.Add(warningStream);
							}
						}
					}
				}
				else
				{
					this.PSWarning.Set(context, arguments.Streams.WarningStream);
				}
			}
			if (arguments.Streams.ProgressStream != null)
			{
				if (this.PSProgress.Expression == null)
				{
					if (hostValues.Parameters["PSProgress"] != null && hostValues.Parameters["PSProgress"].GetType() == typeof(PSDataCollection<ProgressRecord>))
					{
						PSDataCollection<ProgressRecord> progressRecords = hostValues.Parameters["PSProgress"] as PSDataCollection<ProgressRecord>;
						if (progressRecords != arguments.Streams.ProgressStream && progressRecords != null && progressRecords.IsOpen)
						{
							foreach (ProgressRecord progressStream in arguments.Streams.ProgressStream)
							{
								progressRecords.Add(progressStream);
							}
						}
					}
				}
				else
				{
					this.PSProgress.Set(context, arguments.Streams.ProgressStream);
				}
			}
			if (arguments.Streams.VerboseStream != null)
			{
				if (this.PSVerbose.Expression == null)
				{
					if (hostValues.Parameters["PSVerbose"] != null && hostValues.Parameters["PSVerbose"].GetType() == typeof(PSDataCollection<VerboseRecord>))
					{
						PSDataCollection<VerboseRecord> verboseRecords = hostValues.Parameters["PSVerbose"] as PSDataCollection<VerboseRecord>;
						if (verboseRecords != arguments.Streams.VerboseStream && verboseRecords != null && verboseRecords.IsOpen)
						{
							foreach (VerboseRecord verboseStream in arguments.Streams.VerboseStream)
							{
								verboseRecords.Add(verboseStream);
							}
						}
					}
				}
				else
				{
					this.PSVerbose.Set(context, arguments.Streams.VerboseStream);
				}
			}
			if (arguments.Streams.DebugStream != null)
			{
				if (this.PSDebug.Expression == null)
				{
					if (hostValues.Parameters["PSDebug"] != null && hostValues.Parameters["PSDebug"].GetType() == typeof(PSDataCollection<DebugRecord>))
					{
						PSDataCollection<DebugRecord> debugRecords = hostValues.Parameters["PSDebug"] as PSDataCollection<DebugRecord>;
						if (debugRecords != arguments.Streams.DebugStream && debugRecords != null && debugRecords.IsOpen)
						{
							foreach (DebugRecord debugStream in arguments.Streams.DebugStream)
							{
								debugRecords.Add(debugStream);
							}
						}
					}
				}
				else
				{
					this.PSDebug.Set(context, arguments.Streams.DebugStream);
					return;
				}
			}
		}
コード例 #2
0
ファイル: WorkflowJob2.cs プロジェクト: 40a/PowerShell
        /// <summary>
        /// ResumeBookmark
        /// </summary>
        /// <param name="bookmark"></param>
        /// <param name="supportDisconnectedStreams"></param>
        /// <param name="streams"></param>
        /// <param name="exception"></param>
        public void ResumeBookmark(Bookmark bookmark, bool supportDisconnectedStreams, PowerShellStreams<PSObject, PSObject> streams, Exception exception)
        {
            if (bookmark == null) throw new ArgumentNullException("bookmark");
            if (streams == null) throw new ArgumentNullException("streams");
            if (exception == null) throw new ArgumentNullException("exception");

            PSResumableActivityContext arguments = new PSResumableActivityContext(streams);
            arguments.SupportDisconnectedStreams = supportDisconnectedStreams;
            arguments.Failed = true;
            arguments.Error = exception;

            DoResumeBookmark(bookmark, arguments);
        }
コード例 #3
0
ファイル: PSWorkflowJob.cs プロジェクト: nickchal/pash
		public void ResumeBookmark(Bookmark bookmark, bool supportDisconnectedStreams, PowerShellStreams<PSObject, PSObject> streams, Exception exception)
		{
			if (bookmark != null)
			{
				if (streams != null)
				{
					if (exception != null)
					{
						PSResumableActivityContext pSResumableActivityContext = new PSResumableActivityContext(streams);
						pSResumableActivityContext.SupportDisconnectedStreams = supportDisconnectedStreams;
						pSResumableActivityContext.Failed = true;
						pSResumableActivityContext.Error = exception;
						this.DoResumeBookmark(bookmark, pSResumableActivityContext);
						return;
					}
					else
					{
						throw new ArgumentNullException("exception");
					}
				}
				else
				{
					throw new ArgumentNullException("streams");
				}
			}
			else
			{
				throw new ArgumentNullException("bookmark");
			}
		}