コード例 #1
0
        /// <summary>
        /// Populate the row if this <see cref="ParameterOrOverrideBase"/> is state-independent
        /// </summary>
        /// <param name="actualOption">The <see cref="Option"/></param>
        private void PopulateStateIndependentValues(Option actualOption)
        {
            // get the single ParameterValueSetBase
            var valueSet = this.GetValueSet(actualOption: actualOption);

            this.IsPublishable = this.CheckValuesPublishabledStatus(valueSet);

            if (valueSet == null && !this.IsOptionDependent)
            {
                logger.Warn("The value set of Parameter or override {0} is null for a option and state independent. it should not happen.", this.Thing.Iid);
                return;
            }

            // Scalar Type -> Set value to this row
            if (this.Thing.ParameterType is ScalarParameterType)
            {
                if (valueSet != null)
                {
                    this.SetScalarValue(valueSet);
                }
            }
            else
            {
                // Compound -> set value to the component row
                var compoundType = (CompoundParameterType)this.Thing.ParameterType;

                var index = 0;
                foreach (var component in compoundType.Component.SortedItems)
                {
                    if (!(component.Value.ParameterType is ScalarParameterType))
                    {
                        throw new NotImplementedException("Compound of Compound have yet to be implemented.");
                    }

                    var row = new ParameterTypeComponentRowViewModel(component.Value, this.Session, this);
                    this.ContainedRows.Add(row);

                    if (valueSet != null)
                    {
                        row.SetScalarValue(this.Thing, valueSet, index);
                        index++;
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Create or remove a row representing an <see cref="ActualFiniteState"/>
        /// </summary>
        /// <param name="actualOption">The actual option</param>
        /// <param name="actualState">The actual state</param>
        private void UpdateActualStateRow(Option actualOption, ActualFiniteState actualState)
        {
            var existingRow = this.ContainedRows.OfType <ActualFiniteStateRowViewModel>()
                              .SingleOrDefault(x => x.Thing == actualState);

            if (actualState.Kind == ActualFiniteStateKind.FORBIDDEN)
            {
                if (existingRow != null)
                {
                    existingRow.Dispose();
                    this.ContainedRows.Remove(existingRow);
                }

                return;
            }

            // mandatory state
            if (existingRow != null)
            {
                return;
            }

            var valueSet = this.GetValueSet(actualState, actualOption);

            if (valueSet == null)
            {
                logger.Error("product tree: The valueset is null for an actualFiniteState. it should not happen.");
                return;
            }

            var stateRow = new ActualFiniteStateRowViewModel(actualState, this.Session, this);

            this.ContainedRows.Add(stateRow);
            var isStatePublishable = this.CheckValuesPublishabledStatus(valueSet);

            this.IsPublishable = this.IsPublishable || isStatePublishable;

            var compoundType = this.Thing.ParameterType as CompoundParameterType;

            if (compoundType == null)
            {
                stateRow.SetScalarValue(this.Thing, valueSet);
                stateRow.IsPublishable = isStatePublishable;
            }
            else
            {
                stateRow.IsPublishable = isStatePublishable;
                // create nested state row
                var index = 0;
                foreach (var component in compoundType.Component.SortedItems)
                {
                    if (!(component.Value.ParameterType is ScalarParameterType))
                    {
                        throw new NotImplementedException("Compound of Compound have yet to be implemented");
                    }

                    var componentrow = new ParameterTypeComponentRowViewModel(component.Value, this.Session, this);
                    stateRow.ContainedRows.Add(componentrow);

                    componentrow.SetScalarValue(this.Thing, valueSet, index);
                    index++;
                }
            }
        }