Example #1
0
        /// <summary>
        /// Update the values, formula and switch of the provided <see cref="ParameterValueSet"/>
        /// </summary>
        /// <param name="valueSetValues">
        /// The <see cref="ValueSetValues"/> used to update the <see cref="ParameterValueSet"/> clone with
        /// </param>
        public void UpdateClone(ValueSetValues valueSetValues)
        {
            if (this.ClonedThing == null)
            {
                this.SetClonedThing();
            }

            var clonedParameterValueSet = this.ClonedThing as ParameterValueSet;

            if (clonedParameterValueSet != null)
            {
                this.UpdateClone(clonedParameterValueSet, valueSetValues);
                return;
            }

            var clonedParameterOverrideValueSet = this.ClonedThing as ParameterOverrideValueSet;

            if (clonedParameterOverrideValueSet != null)
            {
                this.UpdateClone(clonedParameterOverrideValueSet, valueSetValues);
                return;
            }

            var clonedParameterSubscriptionValueSet = this.ClonedThing as ParameterSubscriptionValueSet;

            if (clonedParameterSubscriptionValueSet != null)
            {
                this.UpdateClone(clonedParameterSubscriptionValueSet, valueSetValues);
            }
        }
Example #2
0
        /// <summary>
        /// Update the values, formula and switch of the provided <see cref="ParameterOverrideValueSet"/>
        /// </summary>
        /// <param name="clone">
        /// The clone of the <see cref="ParameterOverrideValueSet"/> that is to be updated.
        /// </param>
        /// <param name="valueSetValues">
        /// The <see cref="ValueSetValues"/> used to update the <see cref="ParameterOverrideValueSet"/> clone with
        /// </param>
        private void UpdateClone(ParameterOverrideValueSet clone, ValueSetValues valueSetValues)
        {
            try
            {
                clone.Manual[valueSetValues.ComponentIndex] = valueSetValues.ManualValue;
            }
            catch (ArgumentOutOfRangeException)
            {
                clone.ResetManual();
                clone.Manual[valueSetValues.ComponentIndex] = valueSetValues.ManualValue;
            }
            catch (Exception exception)
            {
                throw exception;
            }

            try
            {
                clone.Computed[valueSetValues.ComponentIndex] = valueSetValues.ComputedValue;
            }
            catch (ArgumentOutOfRangeException)
            {
                clone.ResetComputed();
                clone.Computed[valueSetValues.ComponentIndex] = valueSetValues.ComputedValue;
            }
            catch (Exception exception)
            {
                throw exception;
            }

            try
            {
                clone.Formula[valueSetValues.ComponentIndex] = valueSetValues.FormulaValue;
            }
            catch (ArgumentOutOfRangeException)
            {
                clone.ResetFormula();
                clone.Formula[valueSetValues.ComponentIndex] = valueSetValues.FormulaValue;
            }
            catch (Exception exception)
            {
                throw exception;
            }

            try
            {
                clone.Reference[valueSetValues.ComponentIndex] = valueSetValues.ReferenceValue;
            }
            catch (ArgumentOutOfRangeException)
            {
                clone.ResetReference();
                clone.Reference[valueSetValues.ComponentIndex] = valueSetValues.ReferenceValue;
            }
            catch (Exception exception)
            {
                throw exception;
            }

            clone.ValueSwitch = valueSetValues.SwitchKind;
        }
Example #3
0
        /// <summary>
        /// Asserts whether the <see cref="ParameterSubscriptionValueSet"/> that is represented by the current <see cref="ProcessedValueSet"/> is Dirty or not
        /// </summary>
        /// <param name="original">
        /// The <see cref="ParameterSubscriptionValueSet"/> whose values are being compared to assert the dirtyness
        /// </param>
        /// <param name="componentIndex">
        /// The index of the component of the <see cref="CompoundParameterType"/>
        /// </param>
        /// <param name="parameterType">
        /// The <see cref="ParameterType"/> that is referenced by the container <see cref="ParameterSubscriptionValueSet"/>
        /// </param>
        /// <param name="switchKind">
        /// The <see cref="ParameterSwitchKind"/> that is read from the Parameter sheet
        /// </param>
        /// <param name="manualValue">
        /// The manual value that is read from the Parameter sheet
        /// </param>
        /// <param name="valueSetValues">
        /// The <see cref="ValueSetValues"/> that is created and returned as an out when the return value is true.
        /// </param>
        /// <returns>
        /// True when the values in the Parameter sheet are different from the values of the the <see cref="ParameterSubscriptionValueSet"/> that is being represented by the current <see cref="ProcessedValueSet"/>
        /// </returns>
        private bool IsDirty(ParameterSubscriptionValueSet original, int componentIndex, ParameterType parameterType, ParameterSwitchKind switchKind, object manualValue, out ValueSetValues valueSetValues)
        {
            // here we use CultureInfo.InvariantCulture, these are values that are not shown to the user
            // but serve the purpose to update the data-source.
            var stringManualValue = manualValue.ToValueSetString(parameterType);

            bool isManualValueDirty;

            try
            {
                isManualValueDirty = original.Manual[componentIndex] != stringManualValue;
            }
            catch (ArgumentOutOfRangeException e)
            {
                isManualValueDirty = true;
                logger.Debug("The ParameterSubscriptionValueSet.Manual ValueArray has an incorrect number of slots {0}", original.Iid);
            }
            catch (Exception e)
            {
                throw e;
            }

            var isSwitchKindDirty = original.ValueSwitch != switchKind;

            if (isManualValueDirty || isSwitchKindDirty)
            {
                valueSetValues = new ValueSetValues(componentIndex, parameterType, switchKind, stringManualValue, null, null, null);
                return(true);
            }

            valueSetValues = null;
            return(false);
        }
Example #4
0
        /// <summary>
        /// Update the values, formula and switch of the provided <see cref="ParameterSubscriptionValueSet"/>
        /// </summary>
        /// <param name="clone">
        /// The clone of the <see cref="ParameterSubscriptionValueSet"/> that is to be updated.
        /// </param>
        /// <param name="valueSetValues">
        /// The <see cref="ValueSetValues"/> used to update the <see cref="ParameterSubscriptionValueSet"/> clone with
        /// </param>
        private void UpdateClone(ParameterSubscriptionValueSet clone, ValueSetValues valueSetValues)
        {
            try
            {
                clone.Manual[valueSetValues.ComponentIndex] = valueSetValues.ManualValue;
            }
            catch (ArgumentOutOfRangeException)
            {
                clone.ResetManual();
                clone.Manual[valueSetValues.ComponentIndex] = valueSetValues.ManualValue;
            }
            catch (Exception exception)
            {
                throw exception;
            }

            clone.ValueSwitch = valueSetValues.SwitchKind;
        }
Example #5
0
        /// <summary>
        /// Asserts whether the <see cref="ParameterValueSet"/>, <see cref="ParameterOverrideValueSet"/> or <see cref="ParameterSubscriptionValueSet"/> that is represented
        /// by the current <see cref="ProcessedValueSet"/> is Dirty or not
        /// </summary>
        /// <param name="componentIndex">
        /// The index of the component of the <see cref="CompoundParameterType"/>
        /// </param>
        /// <param name="parameterType">
        /// The <see cref="ParameterType"/> that is referenced by the container <see cref="Parameter"/>, <see cref="ParameterOverride"/>, or <see cref="ParameterSubscription"/>
        /// </param>
        /// <param name="switchKind">
        /// The <see cref="ParameterSwitchKind"/> that is read from the Parameter sheet
        /// </param>
        /// <param name="manualValue">
        /// The manual value that is read from the Parameter sheet
        /// </param>
        /// <param name="computedValue">
        /// The computed value that is read from the Parameter sheet
        /// </param>
        /// <param name="referenceValue">
        /// The reference value that is read from the Parameter sheet
        /// </param>
        /// <param name="formulaValue">
        /// The formula value that is read from the Parameter sheet
        /// </param>
        /// <param name="valueSetValues">
        /// The <see cref="ValueSetValues"/> that is created and returned as an out when the return value is true.
        /// </param>
        /// <returns>
        /// True when the values in the Parameter sheet are different from the values of the the <see cref="ParameterValueSet"/>, <see cref="ParameterOverrideValueSet"/>
        /// or <see cref="ParameterSubscriptionValueSet"/> that is being represented by the current <see cref="ProcessedValueSet"/>
        /// </returns>
        public bool IsDirty(int componentIndex, ParameterType parameterType, ParameterSwitchKind switchKind, object manualValue, object computedValue, object referenceValue, string formulaValue, out ValueSetValues valueSetValues)
        {
            var parameterValueSet = this.OriginalThing as ParameterValueSet;

            if (parameterValueSet != null)
            {
                return(this.IsDirty(parameterValueSet, componentIndex, parameterType, switchKind, manualValue, computedValue, referenceValue, formulaValue, out valueSetValues));
            }

            var parameterOverrideValueSet = this.OriginalThing as ParameterOverrideValueSet;

            if (parameterOverrideValueSet != null)
            {
                return(this.IsDirty(parameterOverrideValueSet, componentIndex, parameterType, switchKind, manualValue, computedValue, referenceValue, formulaValue, out valueSetValues));
            }

            var parameterSubscriptionValueSet = this.OriginalThing as ParameterSubscriptionValueSet;

            return(this.IsDirty(parameterSubscriptionValueSet, componentIndex, parameterType, switchKind, manualValue, out valueSetValues));
        }