/// <summary> /// Process the <see cref="ParameterSubscriptionValueSet"/> . /// </summary> /// <param name="parameterSubscriptionValueSet"> /// The <see cref="ParameterSubscriptionValueSet"/> to be processed. /// </param> /// <param name="componentIndex"> /// The index of the <see cref="ParameterTypeComponent"/>. /// </param> /// <param name="currentRow"> /// The row in the Parameter sheet that contains the <see cref="ParameterValueSet"/>. /// </param> /// <param name="manualValue"> /// The manual value of the <see cref="ParameterValueSet"/>. /// </param> /// <param name="switchValue"> /// The string value of the <see cref="ParameterSwitchKind"/> of the <see cref="ParameterSubscriptionValueSet"/> /// </param> /// <param name="valuesets"> /// A <see cref="Dictionary{Guid,ProcessedValueSet}"/> of <see cref="ProcessedValueSet"/>s that capture the updated <see cref="Thing"/>s with its value validation result /// </param> /// <param name="provider"> /// The <see cref="IFormatProvider"/> used to validate. /// </param> /// <returns> /// The <see cref="ValidationResultKind"/> for the <see cref="ParameterSubscriptionValueSet"/> /// </returns> private void ProcessValueSet(ParameterSubscriptionValueSet parameterSubscriptionValueSet, int componentIndex, int currentRow, object manualValue, string switchValue, ref Dictionary <Guid, ProcessedValueSet> valuesets, IFormatProvider provider) { var validationResult = ValidationResultKind.InConclusive; var switchKind = ParameterSwitchKind.MANUAL; ParameterType parameterType = null; MeasurementScale measurementScale = null; ParameterSheetUtilities.QueryParameterTypeAndScale(parameterSubscriptionValueSet, componentIndex, out parameterType, out measurementScale); ValidationResult validSwitch; var isValidSwitchKind = Enum.IsDefined(typeof(ParameterSwitchKind), switchValue); if (isValidSwitchKind) { switchKind = (ParameterSwitchKind)Enum.Parse(typeof(ParameterSwitchKind), switchValue); validSwitch = new ValidationResult { ResultKind = ValidationResultKind.Valid, Message = string.Empty }; } else { switchKind = ParameterSwitchKind.MANUAL; validSwitch = new ValidationResult { ResultKind = ValidationResultKind.Invalid, Message = string.Format("{0} is not a valid Parameter Switch Kind", switchValue) }; } if (validSwitch.ResultKind > validationResult) { validationResult = validSwitch.ResultKind; } var validManualValue = new ValidationResult { ResultKind = ValidationResultKind.InConclusive, Message = string.Empty }; if (parameterType != null) { if (parameterType is TimeOfDayParameterType) { ParameterSheetUtilities.ConvertDoubleToDateTimeObject(ref manualValue, parameterType); } validManualValue = parameterType.Validate(manualValue, measurementScale, provider); if (validManualValue.ResultKind > validationResult) { validationResult = validManualValue.ResultKind; } } ParameterSheetUtilities.Decorate(validManualValue, this.parameterSheet, currentRow, ParameterSheetConstants.ManualColumn); ProcessedValueSet processedValueSet; var valueSetExists = valuesets.TryGetValue(parameterSubscriptionValueSet.Iid, out processedValueSet); if (!valueSetExists) { processedValueSet = new ProcessedValueSet(parameterSubscriptionValueSet, validationResult); } ValueSetValues valueSetValues; if (processedValueSet.IsDirty(componentIndex, parameterType, switchKind, manualValue, null, null, null, out valueSetValues)) { processedValueSet.UpdateClone(valueSetValues); if (!valueSetExists) { valuesets.Add(parameterSubscriptionValueSet.Iid, processedValueSet); } } }