Example #1
0
 internal PSModuleInfo(ExecutionContext context, bool linkToGlobal)
 {
     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 (context == null)
     {
         throw new InvalidOperationException("PSModuleInfo");
     }
     SetDefaultDynamicNameAndPath(this);
     this._sessionState = new System.Management.Automation.SessionState(context, true, linkToGlobal);
     this._sessionState.Internal.Module = this;
 }
Example #2
0
        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;
            }
        }
Example #3
0
 internal PSModuleInfo(string name, string path, ExecutionContext context, System.Management.Automation.SessionState sessionState)
 {
     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 (path != null)
     {
         string resolvedPath = ModuleCmdletBase.GetResolvedPath(path, context);
         this._path = resolvedPath ?? path;
     }
     this._sessionState = sessionState;
     if (sessionState != null)
     {
         sessionState.Internal.Module = this;
     }
     if (name == null)
     {
         this._name = ModuleIntrinsics.GetModuleName(this._path);
     }
     else
     {
         this._name = name;
     }
 }
Example #4
0
 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;
     }
 }
Example #5
0
 internal PSModuleInfo(string name, string path, ExecutionContext context, System.Management.Automation.SessionState sessionState)
 {
     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 (path != null)
     {
         string resolvedPath = ModuleCmdletBase.GetResolvedPath(path, context);
         this._path = resolvedPath ?? path;
     }
     this._sessionState = sessionState;
     if (sessionState != null)
     {
         sessionState.Internal.Module = this;
     }
     if (name == null)
     {
         this._name = ModuleIntrinsics.GetModuleName(this._path);
     }
     else
     {
         this._name = name;
     }
 }
Example #6
0
 internal PSModuleInfo(ExecutionContext context, bool linkToGlobal)
 {
     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 (context == null)
     {
         throw new InvalidOperationException("PSModuleInfo");
     }
     SetDefaultDynamicNameAndPath(this);
     this._sessionState = new System.Management.Automation.SessionState(context, true, linkToGlobal);
     this._sessionState.Internal.Module = this;
 }
Example #7
0
 internal PSModuleInfo(string path, ExecutionContext context, System.Management.Automation.SessionState sessionState) : this(null, path, context, sessionState)
 {
 }