public void BooleanImplicit(bool testValue) { Value value; using (MemoryWatch.Create()) { value = testValue; } Assert.AreEqual(testValue, value.As <bool>()); Assert.AreEqual(typeof(bool), value.Type); bool?source = testValue; using (MemoryWatch.Create()) { value = source; } Assert.AreEqual(source, value.As <bool?>()); Assert.AreEqual(typeof(bool), value.Type); }
private void CreateConfigs() { if (Configs != null) { Configs.ValueChanged -= OnConfigsValueChanged; Configs.Dispose(); } if (!Directory.Exists(_dir)) { Mode = Mode.NoShadersPatch; Configs = null; return; } FileUtils.EnsureDirectoryExists(Path.Combine(AcPaths.GetDocumentsCfgDirectory(), "extension")); var anyConfigFound = false; Configs = new PythonAppConfigs(new PythonAppConfigParams(_dir) { FilesRelativeDirectory = AcRootDirectory.Instance.Value ?? _dir, ScanFunc = d => Directory.GetFiles(d, "*.ini").Where(x => !Path.GetFileName(x).StartsWith(@"data_")), ConfigFactory = (p, f) => { var fileName = Path.GetFileName(f); if (fileName == null) { return(null); } anyConfigFound = true; var userEditedFile = Path.Combine(AcPaths.GetDocumentsCfgDirectory(), "extension", fileName); var cfg = PythonAppConfig.Create(p, f, true, userEditedFile); if (_isLive && cfg.Sections.GetByIdOrDefault("ℹ")?.GetByIdOrDefault("LIVE_SUPPORT")?.Value == @"0") { return(null); } return(string.IsNullOrWhiteSpace(cfg.ShortDescription) ? null : cfg); }, SaveOnlyNonDefault = true, Flags = new Dictionary <string, string> { [@"IS_LIVE__"] = _isLive.As <string>() } }); if (Configs.Count > 0) { Mode = Mode.EverythingIsFine; } else if (anyConfigFound) { Mode = Mode.NoFittingConfigs; } else { Mode = Mode.NoConfigs; } SelectedConfig = Configs.GetByIdOrDefault(_selectedConfigId.Value) ?? Configs.FirstOrDefault(); Configs.ValueChanged += OnConfigsValueChanged; }