Beispiel #1
0
        internal static RunspaceConfigForSingleShell Create(string consoleFile, out PSConsoleLoadException warning)
        {
            PSConsoleLoadException cle = null;

            _mshsnapinTracer.WriteLine("Creating MshConsoleInfo. consoleFile={0}", new object[] { consoleFile });
            MshConsoleInfo consoleInfo = MshConsoleInfo.CreateFromConsoleFile(consoleFile, out cle);

            if (cle != null)
            {
                _mshsnapinTracer.TraceWarning("There was a warning while creating MshConsoleInfo: {0}", new object[] { cle.Message });
            }
            if (consoleInfo != null)
            {
                RunspaceConfigForSingleShell shell      = new RunspaceConfigForSingleShell(consoleInfo);
                PSConsoleLoadException       exception2 = null;
                shell.LoadConsole(out exception2);
                if (exception2 != null)
                {
                    _mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", new object[] { exception2.Message });
                }
                warning = CombinePSConsoleLoadException(cle, exception2);
                return(shell);
            }
            warning = null;
            return(null);
        }
        /// <exception cref="PSSnapInException">
        /// One or more default mshsnapins cannot be loaded because the
        /// registry is not populated correctly.
        /// </exception>
        /// <exception cref="PSArgumentNullException">
        /// fileName is null.
        /// </exception>
        /// <exception cref="PSArgumentException">
        /// fileName does not specify proper file extension.
        /// </exception>
        /// <exception cref="XmlException">
        /// Unable to load/parse the file specified by fileName.
        /// </exception>
        internal new static RunspaceConfigForSingleShell Create(string consoleFile, out PSConsoleLoadException warning)
        {
            PSConsoleLoadException warning1 = null;

            s_mshsnapinTracer.WriteLine("Creating MshConsoleInfo. consoleFile={0}", consoleFile);

            MshConsoleInfo consoleInfo = MshConsoleInfo.CreateFromConsoleFile(consoleFile, out warning1);

            if (warning1 != null)
            {
                s_mshsnapinTracer.TraceWarning("There was a warning while creating MshConsoleInfo: {0}", warning1.Message);
            }

            // At this time, consoleInfo should not be null. 
            // Otherwise, an exception should have been thrown up. 
            if (consoleInfo != null)
            {
                RunspaceConfigForSingleShell rspcfg = new RunspaceConfigForSingleShell(consoleInfo);
                PSConsoleLoadException warning2 = null;

                rspcfg.LoadConsole(out warning2);

                if (warning2 != null)
                {
                    s_mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", warning2.Message);
                }

                warning = CombinePSConsoleLoadException(warning1, warning2);

                return rspcfg;
            }

            warning = null;
            return null;
        }
Beispiel #3
0
        /// <exception cref="PSSnapInException">
        /// One or more default mshsnapins cannot be loaded because the
        /// registry is not populated correctly.
        /// </exception>
        internal static RunspaceConfigForSingleShell CreateDefaultConfiguration()
        {
            s_mshsnapinTracer.WriteLine("Creating default runspace configuration.");

            MshConsoleInfo consoleInfo = MshConsoleInfo.CreateDefaultConfiguration();

            // This should not happen. If there is a failure in creating consoleInfo,
            // an exception should have been thrown up.
            if (consoleInfo != null)
            {
                RunspaceConfigForSingleShell rspcfg  = new RunspaceConfigForSingleShell(consoleInfo);
                PSConsoleLoadException       warning = null;

                rspcfg.LoadConsole(out warning);

                if (warning != null)
                {
                    s_mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", warning.Message);
                }

                return(rspcfg);
            }

            s_mshsnapinTracer.WriteLine("Default runspace configuration created.");

            return(null);
        }
Beispiel #4
0
        /// <exception cref="PSSnapInException">
        /// One or more default mshsnapins cannot be loaded because the
        /// registry is not populated correctly.
        /// </exception>
        /// <exception cref="PSArgumentNullException">
        /// fileName is null.
        /// </exception>
        /// <exception cref="PSArgumentException">
        /// fileName does not specify proper file extension.
        /// </exception>
        /// <exception cref="XmlException">
        /// Unable to load/parse the file specified by fileName.
        /// </exception>
        internal new static RunspaceConfigForSingleShell Create(string consoleFile, out PSConsoleLoadException warning)
        {
            PSConsoleLoadException warning1 = null;

            s_mshsnapinTracer.WriteLine("Creating MshConsoleInfo. consoleFile={0}", consoleFile);

            MshConsoleInfo consoleInfo = MshConsoleInfo.CreateFromConsoleFile(consoleFile, out warning1);

            if (warning1 != null)
            {
                s_mshsnapinTracer.TraceWarning("There was a warning while creating MshConsoleInfo: {0}", warning1.Message);
            }

            // At this time, consoleInfo should not be null.
            // Otherwise, an exception should have been thrown up.
            if (consoleInfo != null)
            {
                RunspaceConfigForSingleShell rspcfg   = new RunspaceConfigForSingleShell(consoleInfo);
                PSConsoleLoadException       warning2 = null;

                rspcfg.LoadConsole(out warning2);

                if (warning2 != null)
                {
                    s_mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", warning2.Message);
                }

                warning = CombinePSConsoleLoadException(warning1, warning2);

                return(rspcfg);
            }

            warning = null;
            return(null);
        }
 internal static RunspaceConfigForSingleShell Create(
     string consoleFile,
     out PSConsoleLoadException warning)
 {
     using (RunspaceConfigForSingleShell.tracer.TraceMethod())
     {
         PSConsoleLoadException cle = (PSConsoleLoadException)null;
         RunspaceConfigForSingleShell._mshsnapinTracer.WriteLine("Creating MshConsoleInfo. consoleFile={0}", (object)consoleFile);
         MshConsoleInfo fromConsoleFile = MshConsoleInfo.CreateFromConsoleFile(consoleFile, out cle);
         if (cle != null)
         {
             RunspaceConfigForSingleShell._mshsnapinTracer.TraceWarning("There was a warning while creating MshConsoleInfo: {0}", (object)cle.Message);
         }
         if (fromConsoleFile != null)
         {
             RunspaceConfigForSingleShell configForSingleShell = new RunspaceConfigForSingleShell(fromConsoleFile);
             PSConsoleLoadException       warning1             = (PSConsoleLoadException)null;
             configForSingleShell.LoadConsole(out warning1);
             if (warning1 != null)
             {
                 RunspaceConfigForSingleShell._mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", (object)warning1.Message);
             }
             warning = RunspaceConfigForSingleShell.CombinePSConsoleLoadException(cle, warning1);
             return(configForSingleShell);
         }
         warning = (PSConsoleLoadException)null;
         return((RunspaceConfigForSingleShell)null);
     }
 }
Beispiel #6
0
 public static RunspaceConfiguration Create(
     string consoleFilePath,
     out PSConsoleLoadException warnings)
 {
     using (RunspaceConfiguration.tracer.TraceMethod())
         return((RunspaceConfiguration)RunspaceConfigForSingleShell.Create(consoleFilePath, out warnings));
 }
Beispiel #7
0
        internal static RunspaceConfigForSingleShell CreateDefaultConfiguration()
        {
            _mshsnapinTracer.WriteLine("Creating default runspace configuration.", new object[0]);
            MshConsoleInfo consoleInfo = MshConsoleInfo.CreateDefaultConfiguration();

            if (consoleInfo != null)
            {
                RunspaceConfigForSingleShell shell   = new RunspaceConfigForSingleShell(consoleInfo);
                PSConsoleLoadException       warning = null;
                shell.LoadConsole(out warning);
                if (warning != null)
                {
                    _mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", new object[] { warning.Message });
                }
                return(shell);
            }
            _mshsnapinTracer.WriteLine("Default runspace configuration created.", new object[0]);
            return(null);
        }
 internal static RunspaceConfigForSingleShell CreateDefaultConfiguration()
 {
     using (RunspaceConfigForSingleShell.tracer.TraceMethod())
     {
         RunspaceConfigForSingleShell._mshsnapinTracer.WriteLine("Creating default runspace configuration.", new object[0]);
         MshConsoleInfo defaultConfiguration = MshConsoleInfo.CreateDefaultConfiguration();
         if (defaultConfiguration != null)
         {
             RunspaceConfigForSingleShell configForSingleShell = new RunspaceConfigForSingleShell(defaultConfiguration);
             PSConsoleLoadException       warning = (PSConsoleLoadException)null;
             configForSingleShell.LoadConsole(out warning);
             if (warning != null)
             {
                 RunspaceConfigForSingleShell._mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", (object)warning.Message);
             }
             return(configForSingleShell);
         }
         RunspaceConfigForSingleShell._mshsnapinTracer.WriteLine("Default runspace configuration created.", new object[0]);
         return((RunspaceConfigForSingleShell)null);
     }
 }
        /// <exception cref="PSSnapInException">
        /// One or more default mshsnapins cannot be loaded because the
        /// registry is not populated correctly.
        /// </exception>
        internal static RunspaceConfigForSingleShell CreateDefaultConfiguration()
        {
            s_mshsnapinTracer.WriteLine("Creating default runspace configuration.");

            MshConsoleInfo consoleInfo = MshConsoleInfo.CreateDefaultConfiguration();

            // This should not happen. If there is a failure in creating consoleInfo,
            // an exception should have been thrown up. 
            if (consoleInfo != null)
            {
                RunspaceConfigForSingleShell rspcfg = new RunspaceConfigForSingleShell(consoleInfo);
                PSConsoleLoadException warning = null;

                rspcfg.LoadConsole(out warning);

                if (warning != null)
                {
                    s_mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", warning.Message);
                }

                return rspcfg;
            }

            s_mshsnapinTracer.WriteLine("Default runspace configuration created.");

            return null;
        }
Beispiel #10
0
 /// <summary>
 /// Create one single shell runspace configuration object for a msh version.
 /// </summary>
 /// <returns></returns>
 public static RunspaceConfiguration Create()
 {
     return(RunspaceConfigForSingleShell.CreateDefaultConfiguration());
 }
Beispiel #11
0
 /// <summary>
 /// Create one single shell runspace configuration object from console file
 /// </summary>
 /// <param name="consoleFilePath"></param>
 /// <param name="warnings"></param>
 /// <returns></returns>
 public static RunspaceConfiguration Create(string consoleFilePath, out PSConsoleLoadException warnings)
 {
     return(RunspaceConfigForSingleShell.Create(consoleFilePath, out warnings));
 }
 internal static RunspaceConfigForSingleShell CreateDefaultConfiguration()
 {
     _mshsnapinTracer.WriteLine("Creating default runspace configuration.", new object[0]);
     MshConsoleInfo consoleInfo = MshConsoleInfo.CreateDefaultConfiguration();
     if (consoleInfo != null)
     {
         RunspaceConfigForSingleShell shell = new RunspaceConfigForSingleShell(consoleInfo);
         PSConsoleLoadException warning = null;
         shell.LoadConsole(out warning);
         if (warning != null)
         {
             _mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", new object[] { warning.Message });
         }
         return shell;
     }
     _mshsnapinTracer.WriteLine("Default runspace configuration created.", new object[0]);
     return null;
 }
 internal static RunspaceConfigForSingleShell Create(string consoleFile, out PSConsoleLoadException warning)
 {
     PSConsoleLoadException cle = null;
     _mshsnapinTracer.WriteLine("Creating MshConsoleInfo. consoleFile={0}", new object[] { consoleFile });
     MshConsoleInfo consoleInfo = MshConsoleInfo.CreateFromConsoleFile(consoleFile, out cle);
     if (cle != null)
     {
         _mshsnapinTracer.TraceWarning("There was a warning while creating MshConsoleInfo: {0}", new object[] { cle.Message });
     }
     if (consoleInfo != null)
     {
         RunspaceConfigForSingleShell shell = new RunspaceConfigForSingleShell(consoleInfo);
         PSConsoleLoadException exception2 = null;
         shell.LoadConsole(out exception2);
         if (exception2 != null)
         {
             _mshsnapinTracer.TraceWarning("There was a warning while loading console: {0}", new object[] { exception2.Message });
         }
         warning = CombinePSConsoleLoadException(cle, exception2);
         return shell;
     }
     warning = null;
     return null;
 }
 public static RunspaceConfiguration Create(bool importSystemModules = false)
 {
     return(RunspaceConfigForSingleShell.CreateDefaultConfiguration());
 }
Beispiel #15
0
 public static RunspaceConfiguration Create()
 {
     using (RunspaceConfiguration.tracer.TraceMethod())
         return((RunspaceConfiguration)RunspaceConfigForSingleShell.CreateDefaultConfiguration());
 }