public PSModuleInfo(ScriptBlock scriptBlock) { this._context = LocalPipeline.GetExecutionContextFromTLS(); if (this._context == null) { throw new InvalidOperationException(nameof(PSModuleInfo)); } PSModuleInfo.SetDefaultDynamicNameAndPath(this); this._sessionState = new SessionState(this._context.EngineSessionState, true, true); this._sessionState.Internal.Module = this; SessionStateInternal engineSessionState = this._context.EngineSessionState; try { ArrayList resultList = (ArrayList)null; this._context.EngineSessionState = this._sessionState.Internal; this._context.EngineSessionState.SetVariableValue("PSScriptRoot", (object)this._path); scriptBlock = scriptBlock.Clone(true); scriptBlock.SessionState = this._sessionState; if (scriptBlock == null) { throw PSModuleInfo.tracer.NewInvalidOperationException(); } scriptBlock.InvokeWithPipe(false, true, (object)AutomationNull.Value, (object)AutomationNull.Value, (object)AutomationNull.Value, (Pipe)null, ref resultList); } finally { this._context.EngineSessionState = engineSessionState; } }
public PSModuleInfo(ScriptBlock scriptBlock) { this._name = string.Empty; this._path = string.Empty; this._description = string.Empty; this._version = new System.Version(0, 0); this._detectedFunctionExports = new List <string>(); this._detectedWorkflowExports = new List <string>(); this._detectedCmdletExports = new List <string>(); this._compiledExports = new List <CmdletInfo>(); this._fileList = new List <string>(); this._moduleList = new Collection <object>(); this._nestedModules = new List <PSModuleInfo>(); this._scripts = new List <string>(); this._requiredAssemblies = new Collection <string>(); this._requiredModules = new List <PSModuleInfo>(); this._requiredModulesSpecification = new List <ModuleSpecification>(); this._detectedAliasExports = new Dictionary <string, string>(); this._exportedFormatFiles = new ReadOnlyCollection <string>(new List <string>()); this._exportedTypeFiles = new ReadOnlyCollection <string>(new List <string>()); if (scriptBlock == null) { throw PSTraceSource.NewArgumentException("scriptBlock"); } ExecutionContext executionContextFromTLS = LocalPipeline.GetExecutionContextFromTLS(); if (executionContextFromTLS == null) { throw new InvalidOperationException("PSModuleInfo"); } SetDefaultDynamicNameAndPath(this); this._sessionState = new System.Management.Automation.SessionState(executionContextFromTLS, true, true); this._sessionState.Internal.Module = this; SessionStateInternal engineSessionState = executionContextFromTLS.EngineSessionState; try { executionContextFromTLS.EngineSessionState = this._sessionState.Internal; executionContextFromTLS.SetVariable(SpecialVariables.PSScriptRootVarPath, this._path); scriptBlock = scriptBlock.Clone(true); scriptBlock.SessionState = this._sessionState; Pipe outputPipe = new Pipe { NullPipe = true }; scriptBlock.InvokeWithPipe(false, ScriptBlock.ErrorHandlingBehavior.WriteToCurrentErrorPipe, AutomationNull.Value, AutomationNull.Value, AutomationNull.Value, outputPipe, null, new object[0]); } finally { executionContextFromTLS.EngineSessionState = engineSessionState; } }
public PSModuleInfo(ScriptBlock scriptBlock) { this._name = string.Empty; this._path = string.Empty; this._description = string.Empty; this._version = new System.Version(0, 0); this._detectedFunctionExports = new List<string>(); this._detectedWorkflowExports = new List<string>(); this._detectedCmdletExports = new List<string>(); this._compiledExports = new List<CmdletInfo>(); this._fileList = new List<string>(); this._moduleList = new Collection<object>(); this._nestedModules = new List<PSModuleInfo>(); this._scripts = new List<string>(); this._requiredAssemblies = new Collection<string>(); this._requiredModules = new List<PSModuleInfo>(); this._requiredModulesSpecification = new List<ModuleSpecification>(); this._detectedAliasExports = new Dictionary<string, string>(); this._exportedFormatFiles = new ReadOnlyCollection<string>(new List<string>()); this._exportedTypeFiles = new ReadOnlyCollection<string>(new List<string>()); if (scriptBlock == null) { throw PSTraceSource.NewArgumentException("scriptBlock"); } ExecutionContext executionContextFromTLS = LocalPipeline.GetExecutionContextFromTLS(); if (executionContextFromTLS == null) { throw new InvalidOperationException("PSModuleInfo"); } SetDefaultDynamicNameAndPath(this); this._sessionState = new System.Management.Automation.SessionState(executionContextFromTLS, true, true); this._sessionState.Internal.Module = this; SessionStateInternal engineSessionState = executionContextFromTLS.EngineSessionState; try { executionContextFromTLS.EngineSessionState = this._sessionState.Internal; executionContextFromTLS.SetVariable(SpecialVariables.PSScriptRootVarPath, this._path); scriptBlock = scriptBlock.Clone(true); scriptBlock.SessionState = this._sessionState; Pipe outputPipe = new Pipe { NullPipe = true }; scriptBlock.InvokeWithPipe(false, ScriptBlock.ErrorHandlingBehavior.WriteToCurrentErrorPipe, AutomationNull.Value, AutomationNull.Value, AutomationNull.Value, outputPipe, null, new object[0]); } finally { executionContextFromTLS.EngineSessionState = engineSessionState; } }