public static Model.EnvironmentInfo TryGetEnvironment(this Dictionary <string, Model.EnvironmentInfo> pThis, string displayName)
        {
            Model.EnvironmentInfo retVal = null;

            foreach (var item in pThis)
            {
                if (string.Equals(item.Value.DisplayName, displayName, StringComparison.OrdinalIgnoreCase))
                {
                    retVal = item.Value;
                    break;
                }
            }

            return(retVal);
        }
Example #2
0
        private void SetEnvironments()
        {
            {
                List <string> rawLines;
                if (Environment.Is64BitProcess)
                {
                    rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(SYSTEMENVIRONMENTS_x64_FILE));
                }
                else
                {
                    rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(SYSTEMENVIRONMENTS_x86_FILE));
                }

                foreach (var item in rawLines)
                {
                    int tipStartPos = item.IndexOf(',');
                    var envVariable = item.Substring(0, tipStartPos);
                    var nextSection = item.Substring(tipStartPos + 1);
                    tipStartPos = nextSection.IndexOf(',');
                    var envValue = nextSection.Substring(0, tipStartPos);
                    nextSection = nextSection.Substring(tipStartPos + 1);
                    tipStartPos = nextSection.IndexOf(',');
                    var displayName = nextSection.Substring(0, tipStartPos);
                    var envTips     = nextSection.Substring(tipStartPos + 1);

                    ToolTipMap.Add(envVariable, envTips);

                    var filePath = new Model.EnvironmentInfo();
                    filePath.VarName      = envVariable;
                    filePath.Tips         = envTips;
                    filePath.DisplayName  = displayName;
                    filePath.RelativePath = envValue;
                    filePath.ShortPath    = envValue.GetAbsolutePath(true);
                    filePath.LongPath     = envValue.GetAbsolutePath(false);

                    SystemEnvironments.Add(envVariable, filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(APPENVIRONMENTS_FILE));

                foreach (var item in rawLines)
                {
                    int tipStartPos = item.IndexOf(',');

                    var envVariable = item.Substring(0, tipStartPos);
                    var envTips     = item.Substring(tipStartPos);

                    ToolTipMap.Add(envVariable, envTips);

                    var filePath = new Model.EnvironmentInfo();
                    filePath.RelativePath = envVariable;
                    filePath.ShortPath    = envVariable.GetAbsolutePath(true);
                    filePath.LongPath     = envVariable.GetAbsolutePath(false);

                    AppEnvironments.Add(envVariable, filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREFOLDERS_FILE));

                foreach (var item in rawLines)
                {
                    var expandedValue = Environment.ExpandEnvironmentVariables(item);

                    var filePath = new Model.FilePath();
                    filePath.RelativePath = item;
                    filePath.ShortPath    = expandedValue;
                    filePath.LongPath     = string.Format(@"\\?\{0}", expandedValue);

                    IgnoreFolders.Add(filePath);
                }
            }

            {
                var rawLines = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREFILES_FILE));

                foreach (var item in rawLines)
                {
                    var expandedValue = Environment.ExpandEnvironmentVariables(item);

                    var filePath = new Model.FilePathEx();
                    filePath.RelativePath = item;
                    filePath.ShortPath    = new Regex(expandedValue.Replace("\\", "\\\\"),
                                                      RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
                    var tempVal = string.Format(@"\\?\{0}", expandedValue);
                    filePath.LongPath = new Regex(tempVal.Replace("\\", "\\\\"),
                                                  RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.Compiled);

                    IgnoreFiles.Add(filePath);
                }
            }

            IgnoreRegKeys = FileUtility.Inst.GetFileLines(GetResourcePath(IGNOREREGISTRYKEYS_FILE));
        }