Ejemplo n.º 1
0
        internal static EnvironmentData Create(Verbosity verbosity)
        {
            var result = new EnvironmentData {
                CommandLine        = Environment.CommandLine,
                FrameworkVersion   = RuntimeEnvironment.GetSystemVersion(),
                MachineName        = Environment.MachineName,
                UserDomainName     = Environment.UserDomainName,
                UserInteractive    = Environment.UserInteractive,
                UserName           = Environment.UserName,
                SystemDirectory    = Environment.SystemDirectory,
                OSVersion          = Environment.OSVersion,
                Version            = Environment.Version,
                HasShutdownStarted = Environment.HasShutdownStarted,
                ProcessorCount     = Environment.ProcessorCount,
                IsMono             = Platform.Current.IsMono,
            };

            if (verbosity > Verbosity.Normal)
            {
                CaptureEnvironmentVariables(result);
                CaptureLogicalDrives(result);
            }

            return(result);
        }
Ejemplo n.º 2
0
        static void CaptureLogicalDrives(EnvironmentData result)
        {
            if (stopDrives)
            {
                return;
            }

            try {
                result.LogicalDrives.AddMany(Environment.GetLogicalDrives());
                return;
            } catch (SecurityException) {
            } catch (IOException) {
            }

            stopDrives = true;
        }
Ejemplo n.º 3
0
        static void CaptureEnvironmentVariables(EnvironmentData result)
        {
            if (stopVariables)
            {
                return;
            }

            try {
                foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
                {
                    result.EnvironmentVariables.Add((string)de.Key, (string)de.Value);
                }
            } catch (SecurityException) {
                // TODO Log this?
                stopVariables = true;
            }
        }