public SettingsInfo(Lazy <IBackgroundImageOptionDefinition, IBackgroundImageOptionDefinitionMetadata> lazy) { Lazy = lazy; var defaultSettings = lazy.Value.GetDefaultImageSettings(); RawSettings = defaultSettings is null ? new RawSettings(lazy.Value.Id) : new RawSettings(lazy.Value.Id, defaultSettings); BackgroundImageSettings = new BackgroundImageSettings(RawSettings); }
public BackgroundImageSettings(RawSettings rawSettings) { if (rawSettings == null) { throw new ArgumentNullException(nameof(rawSettings)); } this.rawSettings = rawSettings; }
BackgroundImageSettingsService(ISettingsService settingsService, IBackgroundImageOptionDefinitionService backgroundImageOptionDefinitionService) { this.settingsService = settingsService; settingsInfos = new Dictionary <string, SettingsInfo>(backgroundImageOptionDefinitionService.AllSettings.Length, StringComparer.Ordinal); foreach (var lazy in backgroundImageOptionDefinitionService.AllSettings) { if (settingsInfos.ContainsKey(lazy.Value.Id)) { continue; } settingsInfos[lazy.Value.Id] = new SettingsInfo(lazy); } var allSettingsIds = new HashSet <string>(backgroundImageOptionDefinitionService.AllSettings.Select(a => a.Value.Id), StringComparer.Ordinal); var rootSection = settingsService.GetOrCreateSection(SETTINGS_GUID); foreach (var section in rootSection.SectionsWithName(SettingsName)) { var rawSettings = new RawSettings(section); if (!rawSettings.IsValid) { continue; } Debug2.Assert(rawSettings.Id is not null); if (!settingsInfos.TryGetValue(rawSettings.Id, out var info)) { continue; } if (!allSettingsIds.Contains(rawSettings.Id)) { continue; } allSettingsIds.Remove(rawSettings.Id); if (info.Lazy.Value.UserVisible) { info.SettingsSection = section; info.RawSettings.CopyFrom(rawSettings); } } }
public ImageSettingsInfo(Lazy <IBackgroundImageOptionDefinition, IBackgroundImageOptionDefinitionMetadata> lazy, RawSettings rawSettings) { Lazy = lazy; RawSettings = rawSettings; }
public BackgroundImageSettings(RawSettings rawSettings) => this.rawSettings = rawSettings ?? throw new ArgumentNullException(nameof(rawSettings));