Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8013


Ignore:
Timestamp:
06/15/12 22:44:01 (12 years ago)
Author:
abeham
Message:

#1851: Enabled to set Value to null for OptionalConstrainedValueParameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r8012 r8013  
    6060    private HashSet<IValueParameter> boolParameters;
    6161    private Dictionary<IValueParameter, HashSet<IItem>> multipleChoiceParameters;
     62    private IItem optionalNullChoice = new BoolValue(); // any item will do
    6263
    6364    private StringBuilder failedInstances;
     
    161162      ClearDetailsView();
    162163
     164      var isOptionalConstrainedValueParameter = typeof(OptionalConstrainedValueParameter<>).IsAssignableFrom(parameter.GetType().GetGenericTypeDefinition());
    163165      var isConstrainedValueParameter =
    164         typeof(OptionalConstrainedValueParameter<>).IsAssignableFrom(parameter.GetType().GetGenericTypeDefinition())
     166        isOptionalConstrainedValueParameter
    165167        || typeof(ConstrainedValueParameter<>).Equals(parameter.GetType().GetGenericTypeDefinition());
    166168
     
    169171        choicesListView.Tag = parameter;
    170172
     173        if (isOptionalConstrainedValueParameter) {
     174          choicesListView.Items.Add(new ListViewItem("-") {
     175            Tag = optionalNullChoice,
     176            Checked = multipleChoiceParameters.ContainsKey(parameter)
     177            && multipleChoiceParameters[parameter].Contains(optionalNullChoice)
     178          });
     179        }
    171180        dynamic constrainedValuedParameter = parameter;
    172181        dynamic validValues = constrainedValuedParameter.ValidValues;
     
    797806          foreach (var m in mcEnumerator.Current) {
    798807            dynamic variantParam = variant.Parameters[m.Key.Name];
     808            if (m.Value == optionalNullChoice) {
     809              variantParam.Value = null;
     810              variant.Name += m.Key.Name + "=null, ";
     811              continue;
     812            }
    799813            var variantEnumerator = ((IEnumerable<object>)variantParam.ValidValues).GetEnumerator();
    800814            var originalEnumerator = ((IEnumerable<object>)((dynamic)m.Key).ValidValues).GetEnumerator();
Note: See TracChangeset for help on using the changeset viewer.