public IParameter MapFrom(IParameter parameterBuilder, IBuildConfiguration buildConfiguration) { var parameter = _cloneManagerForModel.Clone(parameterBuilder); buildConfiguration.AddBuilderReference(parameter, parameterBuilder); return(parameter); }
protected override void Context() { _cloneManager = A.Fake <ICloneManagerForModel>(); _simulationFactory = A.Fake <ICoreSimulationFactory>(); _parameterIdentificationRun = A.Fake <IParameterIdentificationRun>(); _coreUserSettings = A.Fake <ICoreUserSettings>(); _descriptionCreator = A.Fake <ICategorialParameterIdentificationDescriptionCreator>(); _container = A.Fake <Utility.Container.IContainer>(); A.CallTo(() => _container.Resolve <ICoreSimulationFactory>()).Returns(_simulationFactory); _coreUserSettings.MaximumNumberOfCoresToUse = 1; sut = new CategorialParameterIdentificationRunInitializer(_cloneManager, _parameterIdentificationRun, _container, _descriptionCreator, _coreUserSettings); _parameterIdentification = new ParameterIdentification(); _parameterIdentification.Configuration.RunMode = new CategorialParameterIdentificationRunMode(); _simulation = A.Fake <ISimulation>(); _clonedSimulation = A.Fake <ISimulation>(); A.CallTo(() => _simulationFactory.CreateWithCalculationMethodsFrom(_simulation, A <IEnumerable <CalculationMethodWithCompoundName> > ._)).Returns(_clonedSimulation); A.CallTo(() => _cloneManager.Clone(_parameterIdentification)).ReturnsLazily(() => { var pi = new ParameterIdentification(); pi.AddSimulation(_simulation); var identificationParameter = new IdentificationParameter(); identificationParameter.AddLinkedParameter(new ParameterSelection(_simulation, A.Fake <QuantitySelection>())); pi.AddIdentificationParameter(identificationParameter); pi.AddOutputMapping(new OutputMapping { OutputSelection = new SimulationQuantitySelection(_simulation, A.Fake <QuantitySelection>()) }); pi.Configuration.RunMode = new CategorialParameterIdentificationRunMode(); return(pi); }); }
public IContainer MapFrom(IContainer containerBuilder, IBuildConfiguration buildConfiguration) { var container = _cloneManagerForModel.Clone(containerBuilder); addBuilderReference(container, containerBuilder, buildConfiguration); return(container); }
private void updateParameterValueFromParameterStartValues(IModel model, IBuildConfiguration buildConfiguration) { foreach (var parameterStartValue in buildConfiguration.ParameterStartValues) { var pathInModel = _keywordReplacerTask.CreateModelPathFor(parameterStartValue.Path, model.Root); var parameter = pathInModel.Resolve <IParameter>(model.Root); //this can happen if the parameter belongs to a molecule locale properties and the molecule was not created in the container if (parameter == null) { continue; } if (parameterStartValue.Formula != null) { parameter.Formula = _cloneManagerForModel.Clone(parameterStartValue.Formula); _keywordReplacerTask.ReplaceIn(parameter, model.Root); } else { var constantFormula = parameter.Formula as ConstantFormula; var parameterValue = parameterStartValue.StartValue.GetValueOrDefault(double.NaN); if (constantFormula == null) { if (parameterStartValue.OverrideFormulaWithValue) { parameter.Formula = _formulaFactory.ConstantFormula(parameterValue, parameter.Dimension); } else { parameter.Value = parameterValue; } } else { constantFormula.Value = parameterValue; } } //Ensure that parameter in simulation appears no to have been fixed by the user when updated from PSV if (parameterStartValue.OverrideFormulaWithValue) { parameter.IsFixedValue = false; } } }
public IParameter MapFrom(IParameter parameterBuilder, IBuildConfiguration buildConfiguration) { var parameter = _cloneManagerForModel.Clone(parameterBuilder); //We reset the container criteria explicitly in the model instance parameter.ContainerCriteria = null; buildConfiguration.AddBuilderReference(parameter, parameterBuilder); return(parameter); }
private IFormula defaultFormulaBasedOn(IStartValue startValue) { if (startValue.Formula != null) { return(_cloneManagerForModel.Clone(startValue.Formula)); } return(_formulaTask.CreateNewFormula <ConstantFormula>(startValue.Dimension).WithValue(startValue.StartValue.GetValueOrDefault(double.NaN))); }
protected override void Context() { _view = A.Fake <IEditDisplayUnitsView>(); _cloner = A.Fake <ICloneManagerForModel>(); _displayUnitPresenter = A.Fake <IDisplayUnitsPresenter>(); sut = new EditDisplayUnitsPresenter(_view, _cloner, _displayUnitPresenter); sut.Initialize(); _displayUnitManager = new DisplayUnitsManager(); _clonedUnitManager = new DisplayUnitsManager(); A.CallTo(() => _cloner.Clone(_displayUnitManager)).Returns(_clonedUnitManager); }
public void Edit(DisplayUnitsManager displayUnitsManager, string displayUnitsType) { _displayUnitsManagerToEdit = displayUnitsManager; _clonedUnitManager = _cloner.Clone(_displayUnitsManagerToEdit); _displayUnitsPresenter.Edit(_clonedUnitManager); _view.Caption = Captions.ManageDisplayUnits(displayUnitsType); _view.Display(); if (_view.Canceled) { return; } // User confirms changes=> Update _displayUnitsManagerToEdit.UpdatePropertiesFrom(_clonedUnitManager, _cloner); }
private void createEventGroupStructure(IEventGroupBuilder eventGroupBuilder, IEventGroup eventGroup, IBuildConfiguration buildConfiguration) { foreach (var childBuilder in eventGroupBuilder.Children) { //nothing to do for these entities that should not be copied in the model structure if (doesNotBelongIntoModel(childBuilder)) { continue; } if (childBuilder.IsAnImplementationOf <IEventGroupBuilder>()) { var childEventGroup = MapFrom(childBuilder.DowncastTo <IEventGroupBuilder>(), buildConfiguration); eventGroup.Add(childEventGroup); if (childBuilder.IsAnImplementationOf <IApplicationBuilder>()) { createApplication(childBuilder.DowncastTo <IApplicationBuilder>(), childEventGroup, buildConfiguration); } } else if (childBuilder.IsAnImplementationOf <IEventBuilder>()) { eventGroup.Add(_eventMapper.MapFrom(childBuilder.DowncastTo <IEventBuilder>(), buildConfiguration)); } else if (childBuilder.IsAnImplementationOf <IParameter>()) { eventGroup.Add(_parameterMapper.MapFrom(childBuilder.DowncastTo <IParameter>(), buildConfiguration)); } else if (childBuilder.IsAnImplementationOf <IContainer>()) { eventGroup.Add(_containerMapper.MapFrom(childBuilder.DowncastTo <IContainer>(), buildConfiguration)); } else { eventGroup.Add(_cloneManagerForModel.Clone(childBuilder)); } } }
private ExplicitFormula updateFormulaToAmountBase(IFormula originalFormula, IDimension amountDimension) { ExplicitFormula formulaInAmount; if (originalFormula.IsExplicit()) { formulaInAmount = _cloneManagerForModel.Clone(originalFormula.DowncastTo <ExplicitFormula>()); } else { formulaInAmount = _objectBaseFactory.Create <ExplicitFormula>() .WithFormulaString(originalFormula.Calculate(null).ToString(CultureInfo.InvariantCulture)); } formulaInAmount.Dimension = amountDimension; var volumeAlias = _formulaTask.AddParentVolumeReferenceToFormula(formulaInAmount); formulaInAmount.FormulaString = $"({formulaInAmount.FormulaString})*{volumeAlias}"; return(formulaInAmount); }
private void convert(IMoleculeBuilder moleculeBuilder, IMoleculeBuildingBlock moleculeBuildingBlock, IReadOnlyList <IPassiveTransportBuildingBlock> passiveTransportBuildingBlocks) { var allPassiveTransports = moleculeBuilder.GetChildren <ITransportBuilder>().ToList(); if (!allPassiveTransports.Any()) { return; } foreach (var passiveTransport in allPassiveTransports) { moleculeBuilder.RemoveChild(passiveTransport); var defaultName = AppConstants.CompositeNameFor(passiveTransport.Name, moleculeBuilder.Name); foreach (var passiveTransportBuildingBlock in passiveTransportBuildingBlocks) { if (similarPassiveTransportAlreadyExists(passiveTransportBuildingBlock, passiveTransport, defaultName)) { var existingPassiveTransport = passiveTransportBuildingBlock.FindByName(defaultName); existingPassiveTransport.AddMoleculeName(moleculeBuilder.Name); continue; } var passiveTransportClone = _cloneManager.Clone(passiveTransport); passiveTransportClone.Name = _containerTask.CreateUniqueName(passiveTransportBuildingBlock, defaultName, canUseBaseName: true); passiveTransportClone.ForAll = false; passiveTransportClone.AddMoleculeName(moleculeBuilder.Name); passiveTransportClone.Parameters.Each(x => x.BuildMode = ParameterBuildMode.Local); passiveTransportBuildingBlock.Add(passiveTransportClone); passiveTransportBuildingBlock.AddFormula(passiveTransportClone.Formula); } if (moleculeBuildingBlock != null) { moleculeBuildingBlock.FormulaCache.Remove(passiveTransport.Formula); } } }
protected override TObjectBase Clone(TObjectBase objectBase) { return(_cloneManager.Clone(objectBase)); }
protected override void GlobalBecause() { _cloneManagerForModel = IoC.Resolve <ICloneManagerForModel>(); _duplicatedParameterIdentification = _cloneManagerForModel.Clone(_parameterIdentification); }
public IFormula MapFrom(IFormula formulaBuilder, IBuildConfiguration buildConfiguration) { return(_cloneManagerForModel.Clone(formulaBuilder)); }