/// <summary> /// Removes all occurances of the path /// </summary> /// <param name="path">Path to remove</param> private void RemoveFilePath(string path) { // if there are multiple occurrences while (Editors.Select(x => x.FilePath).Contains(path)) { Editors = Editors.Where(x => x.FilePath != path).ToArray(); } }
protected override async Task UpdateCurrentValueAsync() { if (this.predefinedValues == null) { return; } using (await AsyncWork.RequestAsyncWork(this)) { await base.UpdateCurrentValueAsync(); var newValues = new Dictionary <string, bool?> (this.predefinedValues.PredefinedValues.Count); ValueInfo <IReadOnlyList <TValue> >[] values = await Task.WhenAll(Editors.Select (ed => ed.GetValueAsync <IReadOnlyList <TValue> > (Property, Variation)).ToArray()); foreach (ValueInfo <IReadOnlyList <TValue> > valueInfo in values) { if (valueInfo.Value == null || valueInfo.Source == ValueSource.Unset) { foreach (var kvp in this.predefinedValues.PredefinedValues) { newValues[kvp.Key] = null; } continue; } foreach (var kvp in this.predefinedValues.PredefinedValues) { bool currentValue = valueInfo.Value.Contains(kvp.Value); if (newValues.TryGetValue(kvp.Key, out bool?presentValue)) { if (presentValue.HasValue && presentValue.Value != currentValue) { newValues[kvp.Key] = null; } } else { newValues[kvp.Key] = currentValue; } } } this.fromUpdate = true; foreach (var vm in Choices) { if (newValues.TryGetValue(vm.Name, out bool?value)) { vm.IsFlagged = value; } else { vm.IsFlagged = false; } } this.fromUpdate = false; } }
public UpdateAppSettings ToCommand() { return(new UpdateAppSettings { Settings = new AppSettings { Editors = Editors?.Select(x => x.ToEditor()).ToImmutableList() !, HideScheduler = HideScheduler, HideDateTimeModeButton = HideDateTimeModeButton, Patterns = Patterns?.Select(x => x.ToPattern()).ToImmutableList() !, } });
public UpdateAppSettings ToCommand() { return(new UpdateAppSettings { Settings = new AppSettings { HideScheduler = HideScheduler, Patterns = Patterns?.Select(x => new Pattern(x.Name, x.Regex) { Message = x.Message }).ToReadOnlyCollection() !, Editors = Editors?.Select(x => new Editor(x.Name, x.Url)).ToReadOnlyCollection() ! } });
void IExecService.Run() { Editors.Select(e => e.Instance).ForEach(i => i.Initialize(App)); }