Esempio n. 1
0
        public PythonAppConfigSection([NotNull] PythonAppConfigParams configParams, KeyValuePair <string, IniFileSection> pair, [CanBeNull] IniFileSection values)
            : base(pair.Value
                   .Where(x => !x.Key.StartsWith("__HINT"))
                   .Select(x => PythonAppConfigValue.Create(configParams, x,
                                                            pair.Value.Commentaries?.GetValueOrDefault(x.Key)?.Split('\n')[0],
                                                            values?.GetValueOrDefault(x.Key), values != null)).NonNull())
        {
            Key        = pair.Key;
            HintTop    = PrepareHint(pair.Value.GetNonEmpty("__HINT_TOP"));
            HintBottom = PrepareHint(pair.Value.GetNonEmpty("__HINT_BOTTOM"));

            var commentary = pair.Value.Commentary?.Split('\n')[0].Trim();

            if (commentary == @"hidden")
            {
                DisplayName = @"hidden";
            }
            else
            {
                var name = commentary ?? PythonAppConfig.ConvertKeyToName(pair.Key);

                var match = SectionName.Match(name);
                if (match.Success && match.Groups[2].Success && match.Groups[2].Length > 50)
                {
                    name    = PythonAppConfig.CapitalizeFirst(match.Groups[1].Value).Trim();
                    ToolTip = PythonAppConfig.CapitalizeFirst(match.Groups[2].Value).Trim();
                }

                DisplayName = PythonAppConfig.CapitalizeFirst(name);
            }
        }
Esempio n. 2
0
 public PythonAppConfigs([NotNull] PythonAppConfigParams configParams)
     : base((configParams.ScanFunc ?? GetConfigFiles)(configParams.PythonAppLocation)
            .Select(x => configParams.ConfigFactory != null
                         ? configParams.ConfigFactory(configParams, x)
                         : PythonAppConfig.Create(configParams, x, false))
            .Where(x => x?.Sections.Any(y => y.Count > 0) == true)
            .OrderBy(x => x.Order.As(0d)).ThenBy(x => x.DisplayName))
 {
     ConfigParams = configParams;
     UpdateReferenced();
     foreach (var config in this)
     {
         config.ValueChanged += OnValueChanged;
     }
 }