public ConfigurationString AddString() { var n = new ConfigurationString(); SourceNames.Add(n); return(n); }
private void OnServiceChanged() { try { isServiceUpdating = true; string selectedName = SelectedName; SourceNames.Clear(); bool isSelectedNameContained = false; void Add(string name) { if (!isSelectedNameContained) { isSelectedNameContained = name == selectedName; } SourceNames.Add(name); } if (service.All.Count > 1) { Add(AllFeedName); } foreach (IPackageSource source in service.All) { Add(source.Name); } if (isSelectedNameContained) { SelectedName = selectedName; } else if (service.Primary != null) { SelectedName = SourceNames.FirstOrDefault(s => string.Equals(s, service.Primary.Name, StringComparison.CurrentCultureIgnoreCase)); } else { SelectedName = SourceNames.FirstOrDefault(); } } finally { isServiceUpdating = false; } }
private void OnServiceChanged() { string selectedName = SelectedName; SourceNames.Clear(); bool isSelectedNameContained = false; void Add(string name) { if (!isSelectedNameContained) { isSelectedNameContained = name == selectedName; } SourceNames.Add(name); } if (service.All.Count > 1) { Add(AllFeedName); } foreach (IPackageSource source in service.All) { Add(source.Name); } if (isSelectedNameContained) { SelectedName = selectedName; } else if (service.Primary != null) { SelectedName = SourceNames.FirstOrDefault(s => s == service.Primary.Name); } else { SelectedName = SourceNames.FirstOrDefault(); } }
protected override void Update() { if (!IsPowerSource) { base.Update(); if (_oldResults != null) { VerifyCurrent(_updateResults); } _oldResults = _updateResults; if (_pseudoParents.Count == 0) { if (_updateResults.Where(x => x.transform.GetComponent <BaseCircuit>().Current > 0).Any()) { foreach (BaseCircuit circuitInstance in _updateResults.Select(x => x.transform.GetComponent <BaseCircuit>()).Where(x => x.Current > 0)) { _pseudoParents.Add(circuitInstance); } } } else if (_updateResults.Where(x => x.transform.GetComponent <BaseCircuit>().SourceNames.Except(SourceNames).Any() && !_pseudoParents.Contains(x.transform.GetComponent <BaseCircuit>()) && !_pseudoChildren.Contains(x.transform.GetComponent <BaseCircuit>())).Any()) { foreach (BaseCircuit circ in _updateResults.Where(x => x.transform.GetComponent <BaseCircuit>().SourceNames.Except(SourceNames).Any() && !_pseudoParents.Contains(x.transform.GetComponent <BaseCircuit>())).Select(x => x.transform.GetComponent <BaseCircuit>())) { if (!circ.GetType().IsAssignableFrom(typeof(Transistor))) { _pseudoParents.Add(circ); } else if (circ.transform.position.y == transform.position.y && transform.position.x > circ.transform.position.x) { _pseudoParents.Add(circ); } } } if (_pseudoParents.Contains(this)) { _pseudoParents.Remove(this); } if (PseudoParents.Count > 0) { foreach (List <string> source in _pseudoParents.Select(x => x.SourceNames)) { if (!SourceNames.Any() || source.Except(SourceNames).Any()) { foreach (string sourceName in source.Except(SourceNames)) { if (sourceName != gameObject.name) { SourceNames.Add(sourceName); } } } } } List <BaseCircuit> currentConns = _updateResults.Select(x => x.transform.GetComponent <BaseCircuit>()).ToList(); if (currentConns.Where(x => x.Current > 0).Any()) { if (_pseudoParents.Count > 0) { List <BaseCircuit> parents = currentConns.Where(x => _pseudoParents.Contains(x)).ToList(); List <string> results = new List <string>(); foreach (BaseCircuit parent in parents) { foreach (string name in SourceNames) { if (!parent.SourceNames.Contains(name) && !results.Contains(name)) { results.Add(name); } else { results.Remove(name); } } } if (results.Any()) { SourceNames.RemoveAll(x => results.Contains(x)); } } _pseudoParents.RemoveAll(x => x == null); } else { _pseudoParents = new List <BaseCircuit>(); _sourceNames = new List <string>(); _current = 0; } _pseudoChildren.RemoveAll(x => x == null); float power = 0; if (_pseudoParents.Count == 0) { Connected = false; } foreach (BaseCircuit parentCircuit in _pseudoParents) { power += parentCircuit.Current; } Current = power; } }