/// <summary>
        /// Returns a new instance of the FieldLogEventEnvironment class that contains information
        /// about the current environment and state of the system.
        /// </summary>
        /// <returns>The FieldLogEventEnvironment instance.</returns>
        public static FieldLogEventEnvironment Current()
        {
            FieldLogEventEnvironment env = new FieldLogEventEnvironment();

            env.OSType             = OSInfo.Type;
            env.OSVersion          = OSInfo.Version;
            env.OSEdition          = OSInfo.Edition;
            env.OSServicePack      = OSInfo.ServicePack;
            env.OSIs64Bit          = OSInfo.Is64Bit;
            env.OSBuild            = OSInfo.Build;
            env.OSServicePackBuild = OSInfo.ServicePackBuild;
            env.OSProductName      = OSInfo.ProductName;
            env.OSIsAppServer      = OSInfo.IsAppServer;
            env.OSLanguage         = OSInfo.Language;
            env.OSLastBootTime     = OSInfo.LastBootTime;
            env.OSIsFailSafeBoot   = OSInfo.IsFailSafeBoot;
            env.AppCompatLayer     = OSInfo.AppCompatLayer;
            env.ClrType            = OSInfo.ClrType;
            env.MouseButtons       = (byte)OSInfo.MouseButtons;
            env.MaxTouchPoints     = (byte)OSInfo.MaxTouchPoints;
            env.ScreenDpi          = (ushort)OSInfo.ScreenDpi;

            env.CultureName      = Thread.CurrentThread.CurrentCulture.Name;
            env.CurrentDirectory = Environment.CurrentDirectory;
            List <string> envNames = new List <string>();

            foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
            {
                envNames.Add(de.Key.ToString());
            }
            envNames.Sort(StringComparer.OrdinalIgnoreCase);
            StringBuilder envSb = new StringBuilder();

            foreach (string envName in envNames)
            {
                envSb.Append(envName);
                envSb.Append("=");
                envSb.Append(Environment.GetEnvironmentVariable(envName));
                envSb.Append("\n");
            }
            env.EnvironmentVariables = envSb.ToString().TrimEnd();
            env.CpuCount             = (ushort)Environment.ProcessorCount;
            env.HostName             = Environment.MachineName;
            env.UserName             = Environment.UserDomainName + "\\" + Environment.UserName;
            env.IsInteractive        = Environment.UserInteractive;
            env.ExecutablePath       = FL.EntryAssemblyLocation;
            env.CommandLine          = Environment.CommandLine;
            env.AppVersion           = FL.AppVersion;
            env.AppAsmConfiguration  = FL.AppAsmConfiguration;
            env.IsProcess64Bit       = IntPtr.Size == 8;         // .NET 4 only: Environment.Is64BitProcess
            env.ClrVersion           = Environment.Version.ToString();
#if NET20
            env.LocalTimeZoneOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.UtcNow);
#else
            env.LocalTimeZoneOffset = TimeZoneInfo.Local.GetUtcOffset(DateTime.UtcNow);
#endif
            env.ProcessMemory                  = OSInfo.GetProcessPrivateMemory();
            env.PeakProcessMemory              = OSInfo.GetProcessPeakMemory();
            env.TotalMemory                    = OSInfo.GetTotalMemorySize();
            env.AvailableMemory                = OSInfo.GetAvailableMemorySize();
            env.ProcessId                      = System.Diagnostics.Process.GetCurrentProcess().Id;
            env.IsAdministrator                = OSInfo.IsCurrentUserLocalAdministrator();
            env.PrimaryScreenWidth             = (ushort)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            env.PrimaryScreenHeight            = (ushort)System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
            env.PrimaryScreenBitsPerPixel      = (byte)System.Windows.Forms.Screen.PrimaryScreen.BitsPerPixel;
            env.PrimaryScreenWorkingAreaLeft   = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Left;
            env.PrimaryScreenWorkingAreaTop    = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Top;
            env.PrimaryScreenWorkingAreaWidth  = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            env.PrimaryScreenWorkingAreaHeight = (ushort)System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            env.ScreenCount                    = (byte)System.Windows.Forms.Screen.AllScreens.Length;

            // Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=682
            int ptrSize = IntPtr.Size;
            int strSize = ptrSize == 4 ? 20 : 32;

            env.Size = 4 + 4 + 4 + 4 +
                       ptrSize + (env.OSServicePack != null ? strSize + env.OSServicePack.Length * 2 : 0) +
                       4 + 4 + 4 +
                       ptrSize + (env.OSProductName != null ? strSize + env.OSProductName.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.OSLanguage != null ? strSize + env.OSLanguage.Length * 2 : 0) +
                       8 + 4 +
                       ptrSize + (env.AppCompatLayer != null ? strSize + env.AppCompatLayer.Length * 2 : 0) +
                       ptrSize + (env.ClrType != null ? strSize + env.ClrType.Length * 2 : 0) +
                       4 + 4 + 4 +
                       ptrSize + (env.CultureName != null ? strSize + env.CultureName.Length * 2 : 0) +
                       ptrSize + (env.CurrentDirectory != null ? strSize + env.CurrentDirectory.Length * 2 : 0) +
                       ptrSize + (env.EnvironmentVariables != null ? strSize + env.EnvironmentVariables.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.HostName != null ? strSize + env.HostName.Length * 2 : 0) +
                       ptrSize + (env.UserName != null ? strSize + env.UserName.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.ExecutablePath != null ? strSize + env.ExecutablePath.Length * 2 : 0) +
                       ptrSize + (env.CommandLine != null ? strSize + env.CommandLine.Length * 2 : 0) +
                       ptrSize + (env.AppVersion != null ? strSize + env.AppVersion.Length * 2 : 0) +
                       ptrSize + (env.AppAsmConfiguration != null ? strSize + env.AppAsmConfiguration.Length * 2 : 0) +
                       4 +
                       ptrSize + (env.ClrVersion != null ? strSize + env.ClrVersion.Length * 2 : 0) +
                       8 + 8 + 8 + 8 + 8 +
                       4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4;
            return(env);
        }