private void LoadExistingConstraints() { DebugSymbolConstraintCollection existingConstraints = DebugSymbolConstraintCollection.Load(); foreach (DebugSymbolConstraint constraint in existingConstraints) { constraints.Items.Add(constraint); } }
private void save_Click(object sender, EventArgs e) { // Save the selected constraints to the user's settings. DebugSymbolConstraintCollection selectedConstraints = new DebugSymbolConstraintCollection(); for (int i = 0; i < constraints.Items.Count; i++) { selectedConstraints.Add((DebugSymbolConstraint)constraints.Items[i]); } selectedConstraints.Save(); DialogResult = DialogResult.OK; Close(); }
/// <summary> /// Validates a configuration against all <see cref="DebugSymbolConstraint"/> saved in the constraints /// file and checks which of the <see cref="DebugSymbolConstraint"/> are unsatisfied with it. /// </summary> /// <remarks> /// A configuration is considered invalid only if it matches the name of a constraint but does not match /// the requested debug type of that constraint. /// </remarks> private static IEnumerable <DebugSymbolConstraint> GetUnsatisfiedConstraints(string configurationName, string debugType) { DebugSymbolConstraintCollection constraints = DebugSymbolConstraintCollection.Load(); foreach (DebugSymbolConstraint constraint in constraints) { // Is the constraint's configuration name contained in "configuration"? bool configurationNameContained = configurationName.Contains(constraint.ConfigurationName); if (configurationNameContained) { // Is the constraint's requested debug type the same as "debugType"? string requestedDebugInfo = constraint.RequestedDebugInfo.ToString().ToLower(); bool debugTypeMatches = debugType.Equals(requestedDebugInfo); if (!debugTypeMatches) { // This constraint is unsatisfied. yield return(constraint); } } } }