示例#1
0
        /// <summary>
        /// Resolve the properties of the current <see cref="ParameterSubscriptionValueSet"/> from its <see cref="DTO.Thing"/> counter-part
        /// </summary>
        /// <param name="dtoThing">The source <see cref="DTO.Thing"/></param>
        internal override void ResolveProperties(DTO.Thing dtoThing)
        {
            if (dtoThing == null)
            {
                throw new ArgumentNullException("dtoThing");
            }

            var dto = dtoThing as DTO.ParameterSubscriptionValueSet;

            if (dto == null)
            {
                throw new InvalidOperationException(string.Format("The DTO type {0} does not match the type of the current ParameterSubscriptionValueSet POCO.", dtoThing.GetType()));
            }

            this.ExcludedDomain.ResolveList(dto.ExcludedDomain, dto.IterationContainerId, this.Cache);
            this.ExcludedPerson.ResolveList(dto.ExcludedPerson, dto.IterationContainerId, this.Cache);
            this.Manual             = new ValueArray <string>(dto.Manual, this);
            this.ModifiedOn         = dto.ModifiedOn;
            this.RevisionNumber     = dto.RevisionNumber;
            this.SubscribedValueSet = this.Cache.Get <ParameterValueSetBase>(dto.SubscribedValueSet, dto.IterationContainerId) ?? SentinelThingProvider.GetSentinel <ParameterValueSetBase>();
            this.ThingPreference    = dto.ThingPreference;
            this.ValueSwitch        = dto.ValueSwitch;

            this.ResolveExtraProperties();
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ValueSetValues"/> class
 /// </summary>
 /// <param name="componentIndex">
 /// The index of the <see cref="ParameterTypeComponent"/> of the value
 /// </param>
 /// <param name="parameterType">
 /// The <see cref="ParameterType"/> of the container <see cref="Parameter"/>, <see cref="ParameterOverride"/> or <see cref="ParameterSubscription"/>
 /// </param>
 /// <param name="switchKind">
 /// The <see cref="SwitchKind"/> of the valueset
 /// </param>
 /// <param name="manualValue">
 /// The manual value
 /// </param>
 /// <param name="computedValue">
 /// The computed value
 /// </param>
 /// <param name="referenceValue">
 /// the reference value
 /// </param>
 /// <param name="formulaValue">
 /// The formula value
 /// </param>
 public ValueSetValues(int componentIndex, ParameterType parameterType, ParameterSwitchKind switchKind, string manualValue, string computedValue, string referenceValue, string formulaValue)
 {
     this.ComponentIndex = componentIndex;
     this.ParameterType  = parameterType;
     this.SwitchKind     = switchKind;
     this.ManualValue    = manualValue;
     this.ComputedValue  = computedValue;
     this.ReferenceValue = referenceValue;
     this.FormulaValue   = formulaValue;
 }
示例#3
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)
        {
            if (this.OriginalThing is ParameterValueSet parameterValueSet)
            {
                return(this.IsDirty(parameterValueSet, componentIndex, parameterType, switchKind, manualValue, computedValue, referenceValue, formulaValue, out valueSetValues));
            }

            if (this.OriginalThing is ParameterOverrideValueSet parameterOverrideValueSet)
            {
                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));
        }
示例#4
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);
        }
        /// <summary>
        /// Clone existing value sets and update its values
        /// </summary>
        /// <param name="parameterValueSet">New value set value <see cref="IEnumerable{IValueSet}"/></param>
        /// <param name="parameterValueSwitch">New value switch value <see cref="ParameterSwitchKind"/></param>
        /// <param name="parameterValue">New value represented as string</param>
        /// <returns>The value set that will be cloned <see cref="ParameterValueSetBase" /></returns>
        public static ParameterValueSetBase UpdateValueSets(IEnumerable <IValueSet> parameterValueSet, ParameterSwitchKind parameterValueSwitch, string parameterValue)
        {
            var valueSetClone = ((ParameterValueSet)parameterValueSet.FirstOrDefault())?.Clone(false);

            if (valueSetClone == null)
            {
                return(null);
            }

            valueSetClone.ValueSwitch = parameterValueSwitch;
            valueSetClone.Manual      = new ValueArray <string>(new List <string> {
                parameterValue
            });
            valueSetClone.Computed = new ValueArray <string>(new List <string> {
                parameterValue
            });
            valueSetClone.Reference = new ValueArray <string>(new List <string> {
                parameterValue
            });
            valueSetClone.Formula = new ValueArray <string>(new List <string> {
                parameterValue
            });
            valueSetClone.Published = new ValueArray <string>(new List <string> {
                parameterValue
            });

            return(valueSetClone);
        }