Esempio n. 1
0
        internal static MshConsoleInfo CreateFromConsoleFile(string fileName, out PSConsoleLoadException cle)
        {
            _mshsnapinTracer.WriteLine("Creating console info from file {0}", new object[] { fileName });
            MshConsoleInfo info     = CreateDefaultConfiguration();
            string         fullPath = Path.GetFullPath(fileName);

            info.fileName = fullPath;
            info.Load(fullPath, out cle);
            _mshsnapinTracer.WriteLine("Console info created successfully", new object[0]);
            return(info);
        }
Esempio n. 2
0
 internal static MshConsoleInfo CreateFromConsoleFile(
     string fileName,
     out PSConsoleLoadException cle)
 {
     using (MshConsoleInfo.tracer.TraceMethod())
     {
         MshConsoleInfo._mshsnapinTracer.WriteLine("Creating console info from file {0}", (object)fileName);
         MshConsoleInfo defaultConfiguration = MshConsoleInfo.CreateDefaultConfiguration();
         string         fullPath             = Path.GetFullPath(fileName);
         defaultConfiguration.fileName = fullPath;
         defaultConfiguration.Load(fullPath, out cle);
         MshConsoleInfo._mshsnapinTracer.WriteLine("Console info created successfully", new object[0]);
         return(defaultConfiguration);
     }
 }
        /// <summary>
        /// Constructs a <see cref="System.Management.Automation.Runspaces.MshConsoleInfo"/> object from a
        /// Monad console file.
        /// </summary>
        /// <param name="fileName">
        /// Monad console file name. If the filename is not absolute path. Then absolute path is
        /// constructed by using Path.GetFullPath() API.
        /// </param>
        /// <param name="cle">
        /// PSConsoleLoadException occurred while loading this console file. This object
        /// also contains specific PSSnapInExceptions that occurred while loading.
        /// </param>
        /// <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">
        /// 1. fileName does not specify proper file extension.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// fileName contains one or more of the invalid characters defined in System.IO.Path.InvalidPathChars.
        /// </exception>
        /// <exception cref="XmlException">
        /// Unable to load/parse the file specified by fileName.
        /// </exception>
        internal static MshConsoleInfo CreateFromConsoleFile(string fileName, out PSConsoleLoadException cle)
        {
            s_mshsnapinTracer.WriteLine("Creating console info from file {0}", fileName);

            // Construct default mshsnapins
            MshConsoleInfo consoleInfo = CreateDefaultConfiguration();

            // Check whether the filename specified is an absolute path.
            string absolutePath = Path.GetFullPath(fileName);

            consoleInfo.Filename = absolutePath;

            // Construct externalPSSnapIns by loading file.
            consoleInfo.Load(absolutePath, out cle);

            s_mshsnapinTracer.WriteLine("Console info created successfully");

            return(consoleInfo);
        }