示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorkbookRebuildRowViewModel"/> class.
 /// </summary>
 /// <param name="parameterValueSet">
 /// The <see cref="ParameterValueSet"/> that is represented by the current view model
 /// </param>
 /// <param name="componentIndex">
 /// The component index.
 /// </param>
 /// <param name="validationResult">
 /// The result of the Validation
 /// </param>
 public WorkbookRebuildRowViewModel(ParameterValueSet parameterValueSet, int componentIndex, ValidationResultKind validationResult)
 {
     this.Thing              = parameterValueSet;
     this.IsSelected         = true;
     this.ModelCode          = parameterValueSet.ModelCode(componentIndex);
     this.ManualValue        = parameterValueSet.Manual[componentIndex];
     this.ReferenceValue     = parameterValueSet.Reference[componentIndex];
     this.FormulaValue       = parameterValueSet.Formula[componentIndex];
     this.ComputedValue      = parameterValueSet.Computed[componentIndex];
     this.ActualValue        = parameterValueSet.ActualValue[componentIndex];
     this.Switch             = parameterValueSet.ValueSwitch.ToString();
     this.HasValidationError = validationResult != ValidationResultKind.Valid;
     this.IsSelected         = this.HasValidationError == false;
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ComponentExcelRow"/> class.
        /// </summary>
        /// <param name="parameterTypeComponent">
        /// The <see cref="ParameterTypeComponent"/> that represents the current row
        /// </param>
        /// <param name="parameterValueSet">
        /// The <see cref="ParameterValueSet"/> from which the value is to be represented
        /// </param>
        /// <param name="level">
        /// the grouping level of the current row.
        /// </param>
        public ComponentExcelRow(ParameterTypeComponent parameterTypeComponent, ParameterValueSet parameterValueSet, int level)
            : base(parameterTypeComponent)
        {
            this.Level         = level;
            this.Name          = string.Format("{0}{1}", new string(' ', 3 * level), parameterTypeComponent.ShortName);
            this.ShortName     = parameterTypeComponent.ShortName;
            this.Type          = ParameterSheetConstants.PVSCT;
            this.Switch        = parameterValueSet.ValueSwitch.ToString();
            this.Id            = string.Format("{0}:{1}", parameterValueSet.Iid, parameterTypeComponent.Index);
            this.Owner         = parameterValueSet.Owner.ShortName;
            this.ParameterType = parameterTypeComponent.ParameterType;

            this.Format = NumberFormat.Format(parameterTypeComponent.ParameterType, parameterTypeComponent.Scale);

            this.ModelCode = parameterValueSet.ModelCode(parameterTypeComponent.Index);

            if (parameterTypeComponent.Scale == null)
            {
                this.ParameterTypeShortName = parameterTypeComponent.ParameterType.ShortName;
            }
            else
            {
                this.ParameterTypeShortName = string.Format("{0} [{1}]", parameterTypeComponent.ParameterType.ShortName, parameterTypeComponent.Scale.ShortName);
            }

            try
            {
                this.ActualValue    = ParameterValueConverter.ConvertToObject(this.Thing.ParameterType, parameterValueSet.ActualValue[parameterTypeComponent.Index]);
                this.ComputedValue  = ParameterValueConverter.ConvertToObject(this.Thing.ParameterType, parameterValueSet.Computed[parameterTypeComponent.Index]);
                this.ManualValue    = ParameterValueConverter.ConvertToObject(this.Thing.ParameterType, parameterValueSet.Manual[parameterTypeComponent.Index]);
                this.ReferenceValue = ParameterValueConverter.ConvertToObject(this.Thing.ParameterType, parameterValueSet.Reference[parameterTypeComponent.Index]);
                this.Formula        = parameterValueSet.Formula[parameterTypeComponent.Index];
            }
            catch (Exception ex)
            {
                this.SetDefaultValues();
                Logger.Debug(ex);
            }
        }
示例#3
0
        public void Verify_that_when_container_not_set_ModelCode_throws_exception()
        {
            var parameterValueSet = new ParameterValueSet(Guid.NewGuid(), null, null);

            Assert.Throws <ContainmentException>(() => parameterValueSet.ModelCode(0));
        }