コード例 #1
0
        private DefaultWorkflowHost()
        {
            const string applicationPrivateData = @"
                <PrivateData>
                    <Param Name='AllowedActivity' Value='PSDefaultActivities' />
                </PrivateData>
";
            var          runtime = PSWorkflowRuntime.Instance;

            runtime.Configuration.Populate(applicationPrivateData, "Microsoft.PowerShell.Workflow");
            _activityHostController = runtime.PSActivityHostController;
            _runspaceProvider       = runtime.RemoteRunspaceProvider;
            _localRunspaceProvider  = runtime.LocalRunspaceProvider;
        }
コード例 #2
0
        private DefaultWorkflowHost()
        {
            try
            {
                this._serviceCore = Assembly.Load("Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
            }
            catch (ArgumentNullException argumentNullException)
            {
            }
            catch (FileNotFoundException fileNotFoundException)
            {
            }
            catch (FileLoadException fileLoadException)
            {
            }
            catch (BadImageFormatException badImageFormatException)
            {
            }
            catch (SecurityException securityException)
            {
            }
            catch (ArgumentException argumentException)
            {
            }
            catch (PathTooLongException pathTooLongException)
            {
            }
            Type         type     = this._serviceCore.GetType("Microsoft.PowerShell.Workflow.PSWorkflowRuntime");
            PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.NonPublic);
            object       value    = property.GetValue(null, null);

            property = value.GetType().GetProperty("Configuration");
            PSWorkflowConfigurationProvider pSWorkflowConfigurationProvider = (PSWorkflowConfigurationProvider)property.GetValue(value, null);

            pSWorkflowConfigurationProvider.Populate("\r\n                <PrivateData>\r\n                    <Param Name='AllowedActivity' Value='PSDefaultActivities' />\r\n                </PrivateData>\r\n", "Microsoft.PowerShell.Workflow");
            property = value.GetType().GetProperty("PSActivityHostController", BindingFlags.Instance | BindingFlags.Public);
            this._activityHostController = (PSActivityHostController)property.GetValue(value, null);
            property = value.GetType().GetProperty("RemoteRunspaceProvider", BindingFlags.Instance | BindingFlags.Public);
            this._runspaceProvider = (RunspaceProvider)property.GetValue(value, null);
            property = value.GetType().GetProperty("LocalRunspaceProvider", BindingFlags.Instance | BindingFlags.Public);
            this._localRunspaceProvider = (RunspaceProvider)property.GetValue(value, null);
        }
コード例 #3
0
ファイル: DefaultWorkflowHost.cs プロジェクト: nickchal/pash
		private DefaultWorkflowHost()
		{
			try
			{
				this._serviceCore = Assembly.Load("Microsoft.PowerShell.Workflow.ServiceCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL");
			}
			catch (ArgumentNullException argumentNullException)
			{
			}
			catch (FileNotFoundException fileNotFoundException)
			{
			}
			catch (FileLoadException fileLoadException)
			{
			}
			catch (BadImageFormatException badImageFormatException)
			{
			}
			catch (SecurityException securityException)
			{
			}
			catch (ArgumentException argumentException)
			{
			}
			catch (PathTooLongException pathTooLongException)
			{
			}
			Type type = this._serviceCore.GetType("Microsoft.PowerShell.Workflow.PSWorkflowRuntime");
			PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.NonPublic);
			object value = property.GetValue(null, null);
			property = value.GetType().GetProperty("Configuration");
			PSWorkflowConfigurationProvider pSWorkflowConfigurationProvider = (PSWorkflowConfigurationProvider)property.GetValue(value, null);
			pSWorkflowConfigurationProvider.Populate("\r\n                <PrivateData>\r\n                    <Param Name='AllowedActivity' Value='PSDefaultActivities' />\r\n                </PrivateData>\r\n", "Microsoft.PowerShell.Workflow");
			property = value.GetType().GetProperty("PSActivityHostController", BindingFlags.Instance | BindingFlags.Public);
			this._activityHostController = (PSActivityHostController)property.GetValue(value, null);
			property = value.GetType().GetProperty("RemoteRunspaceProvider", BindingFlags.Instance | BindingFlags.Public);
			this._runspaceProvider = (RunspaceProvider)property.GetValue(value, null);
			property = value.GetType().GetProperty("LocalRunspaceProvider", BindingFlags.Instance | BindingFlags.Public);
			this._localRunspaceProvider = (RunspaceProvider)property.GetValue(value, null);
		}
コード例 #4
0
        /// <summary>
        /// Dispose implementation.
        /// </summary>
        /// <param name="disposing"></param>
        private void Dispose(bool disposing)
        {
            if (_isDisposed || !disposing)
                return;

            lock (_syncObject)
            {
                if (_isDisposed)
                    return;

                // Suspend all running jobs then dispose all runspace providers
                if (jobManager != null)
                    jobManager.Dispose();
                jobManager = null;

                var remoteRunspaceProvider = _runspaceProvider as ConnectionManager;
                if (remoteRunspaceProvider != null)
                    remoteRunspaceProvider.Dispose();
                _runspaceProvider = null;

                var localRunspaceProvider = _localRunspaceProvider as LocalRunspaceProvider;
                if (localRunspaceProvider != null)
                    localRunspaceProvider.Dispose();
                _localRunspaceProvider = null;

                var unboundedLocalRunspaceProvider = _localRunspaceProvider as LocalRunspaceProvider;
                if (unboundedLocalRunspaceProvider != null)
                    unboundedLocalRunspaceProvider.Dispose();
                _unboundedLocalRunspaceProvider = null;

                activityHostController = null;

                _isDisposed = true;
            }
        }