protected internal BinaryFormula(NodeType nodeType, IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) : base(nodeType, type, parent) { Left = left; Method = method; Right = right; }
protected internal ConditionalFormula(IFormula test, IFormula ifTrue, IFormula ifFalse, ITypeDeclaration type, IFormula parent) : base(NodeType.Conditional, type, parent) { Test = test; IfTrue = ifTrue; IfFalse = ifFalse; }
public void TestSerialization() { ApplicationBuilder x1 = CreateObject <ApplicationBuilder>().WithName("App.Builder"); IFormula f1 = CreateObject <ConstantFormula>().WithValue(2.3); IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(3.4); IParameter p1 = CreateObject <Parameter>().WithName("Patricia").WithFormula(f1).WithValue(3.1); IParameter p2 = CreateObject <Parameter>().WithName("Pascal").WithFormula(f1).WithValue(3.2); x1.Add(p1); x1.Add(p2); EventBuilder eb1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength).WithFormula(f1); EventBuilder eb2 = CreateObject <EventBuilder>().WithName("Eva.Builder").WithDimension(DimensionLength).WithFormula(f2); eb2.OneTime = true; x1.Add(eb1); x1.Add(eb2); var applicationMoleculeBuilder = CreateObject <ApplicationMoleculeBuilder>().WithName("AppMolecule"); applicationMoleculeBuilder.Formula = f2; applicationMoleculeBuilder.RelativeContainerPath = new ObjectPath(new[] { "A", "B" }); x1.AddMolecule(applicationMoleculeBuilder); x1.AddTransport(CreateObject <TransportBuilder>().WithName("PassiveTranport").WithFormula(f1)); ApplicationBuilder x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualApplicationBuilder(x1, x2); }
public void TestSerialization() { EventBuilder x1 = CreateObject <EventBuilder>().WithName("Eve.Builder").WithDimension(DimensionLength); x1.Formula = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4); x1.OneTime = true; IFormula f1 = CreateObject <ExplicitFormula>().WithDimension(DimensionLength).WithFormulaString("3*Patty"); IFormulaUsablePath fup = new FormulaUsablePath(new string[] { "Patricia" }).WithAlias("Patty").WithDimension(DimensionLength); f1.AddObjectPath(fup); IFormula f2 = CreateObject <ConstantFormula>().WithDimension(DimensionLength).WithValue(23.4); IParameter p1 = WithExtensions.WithValue <Parameter>(CreateObject <Parameter>().WithName("Patricia").WithFormula(f1), 3.1); IParameter p2 = WithExtensions.WithValue <Parameter>(CreateObject <Parameter>().WithName("Pascal").WithFormula(f1), 3.2); x1.AddParameter(p1); x1.AddParameter(p2); IEventAssignmentBuilder eab1 = CreateObject <EventAssignmentBuilder>().WithDimension(DimensionLength).WithFormula(f1).WithName("eab1"); IEventAssignmentBuilder eab2 = CreateObject <EventAssignmentBuilder>().WithFormula(f2).WithName("eab2"); x1.AddAssignment(eab1); x1.AddAssignment(eab2); var x2 = SerializeAndDeserialize(x1); AssertForSpecs.AreEqualEventBuilder(x1, x2); }
protected override void Context() { base.Context(); _explicitFormula = new ExplicitFormula(); //another path _explicitFormula.AddObjectPath(new FormulaUsablePath(ObjectPath.PARENT_CONTAINER, ObjectPath.PARENT_CONTAINER, Constants.Parameters.VOLUME, Constants.Parameters.VOLUME).WithAlias(Constants.VOLUME_ALIAS)); }
protected override void Context() { _containerTask = A.Fake <IContainerTask>(); _objectBaseFactory = A.Fake <IObjectBaseFactory>(); _projectRetriever = A.Fake <IMoBiProjectRetriever>(); _eventPublisher = A.Fake <IEventPublisher>(); _cloneManagerForModel = A.Fake <ICloneManagerForModel>(); _formulaTask = A.Fake <IFormulaTask>(); sut = new PassiveTransportConverter(_objectBaseFactory, _projectRetriever, _containerTask, _eventPublisher, _cloneManagerForModel, _formulaTask); A.CallTo(() => _containerTask.CreateUniqueName(A <IEnumerable <IWithName> > ._, A <string> ._, true)) .ReturnsLazily(x => x.Arguments[1].ToString()); _passiveTransportKinetic = new ExplicitFormula("1+2"); _moleculeWithPassiveTransport = new MoleculeBuilder().WithName("MOLECULE"); _passiveTransport = new TransportBuilder().WithName("PASSIVE TRANSPORT").WithFormula(_passiveTransportKinetic); _moleculeWithPassiveTransport.Add(_passiveTransport); _passiveTransports = new PassiveTransportBuildingBlock(); _molecules = new MoleculeBuildingBlock { _moleculeWithPassiveTransport }.WithName("MBB"); _project = new MoBiProject(); A.CallTo(() => _projectRetriever.Current).Returns(_project); A.CallTo(() => _eventPublisher.PublishEvent(A <ShowNotificationsEvent> ._)) .Invokes(x => _showNotificationEvent = x.GetArgument <ShowNotificationsEvent>(0)); }
protected override void Context() { base.Context(); _concentrationFormula = A.Fake <IFormula>(); _formulaCache = new FormulaCache(); A.CallTo(() => _formulaFactory.ConcentrationFormulaFor(_formulaCache)).Returns(_concentrationFormula); }
private void convertExplicitFormula(IFormula formula, IDimension targetDimension) { if (Equals(formula.Dimension, targetDimension)) { return; } var explicitFormula = formula as ExplicitFormula; if (explicitFormula == null) { return; } explicitFormula.Dimension = targetDimension; if (_amoutToConcentrationFormulaMapper.HasMappingFor(explicitFormula)) { explicitFormula.FormulaString = _amoutToConcentrationFormulaMapper.MappedFormulaFor(explicitFormula); return; } var volumeAlias = _formulaTask.AddParentVolumeReferenceToFormula(explicitFormula); explicitFormula.FormulaString = string.Format("({0})/{1}", explicitFormula.FormulaString, volumeAlias); }
/// <summary> /// 获取行为节点 /// </summary> /// <param name="paramsPacker"></param> /// <returns>暂停行为节点</returns> public override IFormula GetFormula(FormulaParamsPacker paramsPacker) { IFormula result = null; // 数据本地化 var myCheckTime = CheckTime; result = new Formula((callback, scope) => { //Debug.Log("Pause"); var timer = new Timer(myCheckTime); Action completeCallback = () => { }; completeCallback = () => { if (SkillManager.isPause) { // 继续暂停 timer = new Timer(myCheckTime); timer.OnCompleteCallback(completeCallback).Start(); } else { // 暂停结束 callback(); } }; timer.OnCompleteCallback(completeCallback); timer.Start(); }, FormulaType); return(result); }
protected override void Context() { base.Context(); _cachedFormula = MvExplicitFormula(); _buildingBlock.FormulaCache.Add(_cachedFormula); A.CallTo(() => _formulaTask.FormulasAreTheSame(_cachedFormula, _usingFormulaObject.Formula)).Returns(true); }
protected override void Context() { base.Context(); _parameter = A.Fake <IParameter>(); _formula = A.Fake <IFormula>(); _dimension = A.Fake <IDimension>(); _group = A.Fake <IGroup>(); _parameter.Formula = _formula; _parameter.RHSFormula = null; _name = "Para"; _parameter.Name = _name; _parameter.GroupName = "TOTO"; _parameter.Persistable = true; _parameter.Visible = true; _parameter.Dimension = _dimension; _parameterBuildMode = ParameterBuildMode.Global; _parameter.BuildMode = _parameterBuildMode; _tag = new Tag("Unsinn"); _otherTag = new Tag("Quatsch"); _parameter.CanBeVariedInPopulation = true; _pathElements = new PathElements(); A.CallTo(() => _pathToPathElementsMapper.MapFrom(_parameter)).Returns(_pathElements); A.CallTo(() => _parameter.Tags).Returns(new Tags(new[] { _tag, _otherTag })); A.CallTo(() => _groupRepository.GroupByName(_parameter.GroupName)).Returns(_group); }
public void Create_Formula_That_Not_Exist() { List <FormulaName> formulaNames = CalculationFormulaFactory.GetAll(); IFormula formula = CalculationFormulaFactory.Create(FormulaType.AreaBased); Assert.IsNotNull(formula, "formala is created"); }
private IFormula checkFormula(IFormulaCache formulaCache, IFormula formula) { if (formula.IsExplicit()) { return(checkFormulaByType(formulaCache, (ExplicitFormula)formula, AreEqualExplicitFormula)); } if (formula.IsBlackBox()) { return(checkFormulaByType(formulaCache, (BlackBoxFormula)formula, AreEqualBalckBoxFormula)); } if (formula.IsTable()) { return(checkFormulaByType(formulaCache, (TableFormula)formula, AreEqualTableFormula)); } if (formula.IsTableWithOffSet()) { return(checkFormulaByType(formulaCache, (TableFormulaWithOffset)formula, AreEqualTableFormulaWithOffset)); } if (formula.IsDynamic()) { return(checkFormulaByType(formulaCache, (SumFormula)formula, AreEqualSumFormula)); } return(formula); }
protected override void Visit(IFormula formula) { if (formula.IsCachable()) { return; } unregister(formula); }
protected override void Context() { base.Context(); _validFormula = A.Fake <IFormula>().WithId("VALID"); _invalidFormula = A.Fake <IFormula>().WithId("INVALID"); sut.Handle(new FormulaInvalidEvent(_validFormula, _buildingBlock, "VALID_MESSAGE")); sut.Handle(new FormulaInvalidEvent(_invalidFormula, _buildingBlock, "INVALID_MESSAGE")); }
private void reportFormulaObjectPaths(IFormula formula, int noOfTabs) { foreach (var path in formula.ObjectPaths) { _report.AppendFormat("{0}{1}: {2}", tabs(noOfTabs), path.Alias, path); _report.AppendLine(); } }
private bool formulaIsBeingEdited(IFormula formula) { if (_editPresenter == null) { return(false); } return(Equals(_editPresenter.Subject, formula)); }
public static void ReplaceKeywordInObjectPaths( this IFormula formula, string keyword, string replacementValue) { ReplaceKeywordsInObjectPaths(formula, new [] { keyword }, new [] { replacementValue }); }
protected override void Context() { base.Context(); _formula = A.Fake <IFormula>(); A.CallTo(() => _formula.ObjectPaths).Returns(new List <IFormulaUsablePath> { A.Fake <IFormulaUsablePath>() }); }
public void RemoveFormulaFromCache(IFormula formula) { if (!Formulas.Contains(formula)) { return; } Formulas.Remove(formula); }
protected override void Context() { base.Context(); _formula = new ExplicitFormula("TOTO"); _reactionBuilder = A.Fake <IReactionBuilder>(); A.CallTo(() => _reactionDimensionRetriever.SelectedDimensionMode).Returns(ReactionDimensionMode.ConcentrationBased); A.CallTo(() => _moBiFormulaTask.GetFormulaCaption(_reactionBuilder, ReactionDimensionMode.ConcentrationBased, false)).Returns("THE_RHS_CAPTION"); }
public DpllAlgorithm(Formula formula) { Contract.Requires(formula != null); _logger = LogManager.GetCurrentClassLogger(); _logger.Info("Hallo"); _formula = formula; }
protected override void Context() { base.Context(); _exisitingFormula = A.Fake <IFormula>().WithId(CoreConstants.Formula.Concentration); _formulaCache = new FormulaCache { _exisitingFormula }; }
protected override void Context() { base.Context(); _formula = new ExplicitFormula("TOTO"); _parameter = A.Fake <IParameter>().WithName("PARA"); sut.IsRHS = true; A.CallTo(() => _moBiFormulaTask.GetFormulaCaption(_parameter, A <ReactionDimensionMode> ._, true)).Returns("THE_RHS_CAPTION"); }
private void renameAbsolutePathIn(IFormula formula) { if (formula == null || !formula.IsExplicit()) { return; } formula.ObjectPaths.Where(isAbsolutePath).Each(renameObjectPath); }
protected override void Context() { base.Context(); _formula = new ExplicitFormula(); _passiveTransportBuildingBlock = new PassiveTransportBuildingBlock(); _passiveTransportBuildingBlock.AddFormula(_formula); sut.Edit(_passiveTransportBuildingBlock); }
protected override void Context() { base.Context(); _existingFormula = A.Fake <IFormula>().WithId("existingId"); _anotherFormulaWithSameId = A.Fake <IFormula>().WithId(_existingFormula.Id); _aDifferentFormula = A.Fake <IFormula>().WithId("toto"); sut.Add(_existingFormula); }
private FormulaExport mapFormula(IUsingFormula usingFormula, IFormula formula) { var formulaExport = createFormulaExport(usingFormula, formula); _modelExport.FormulaList.Add(formulaExport); formulaExport.Id = _modelExport.NewId(); return(formulaExport); }
public override void RestoreExecutionData(IMoBiContext context) { base.RestoreExecutionData(context); _startValuesBuildingBlock = context.Get <IStartValuesBuildingBlock <T> >(_objectBaseId); _changedStartValue = _startValuesBuildingBlock.Single(startValue => startValue.Path.Equals(Path)); _oldFormula = GetFormula(_oldFormulaId, context); _newFormula = GetFormula(_newFormulaId, context); }
protected override void ClearReferences() { base.ClearReferences(); _changedStartValue = null; _startValuesBuildingBlock = null; _newFormula = null; _oldFormula = null; }
public bool EditNewFormula(IFormula formula, ICommandCollector command, IBuildingBlock buildingBlock, IParameter parameter) { using (var presenter = _applicationController.Start <INewFormulaPresenter>()) { presenter.InitializeWith(command); return(presenter.Edit(formula, buildingBlock, parameter)); } }
protected override void Context() { base.Context(); _displayUnit = A.Fake <Unit>(); _constantFormula = new ConstantFormula(5); A.CallTo(() => _formulaFactory.ConstantFormula(5, _dimensionFactory.NoDimension)).Returns(_constantFormula); A.CallTo(() => _displayUnitRetriever.PreferredUnitFor(_dimensionFactory.NoDimension)).Returns(_displayUnit); }
public static IBlockFormula Block( IBlockFormula parentBlock, ReadOnlyCollection<IBlockFormula> childBlocks, ReadOnlyCollection<IFormula> variables, ReadOnlyCollection<IFormula> formulas, IFormula result, ITypeDeclaration type, IFormula parent) { return new BlockFormula(parentBlock, childBlocks, variables, formulas, result, type, parent); }
protected internal MethodCallFormula( IFormula instance, IMethodDeclaration method, ReadOnlyCollection<IFormula> arguments, ITypeDeclaration type, IFormula parent) : base(NodeType.Call, type, parent) { Instance = instance; Method = method; Arguments = arguments; }
static long IterateCalcuations(double[] args, IFormula formula, long iterations) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (long i = 0; i <= iterations; i++) { formula.calculate(args); } stopwatch.Stop(); return stopwatch.ElapsedMilliseconds; }
protected internal ConstantFormula(object value, ITypeDeclaration type, IFormula parent) : base(NodeType.Constant, type, parent) { Value = value; }
protected internal AndAlsoFormula(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) : base(NodeType.AndAlso, left, right, type, method, parent) { }
//protected internal Formula(IConstantNode<NodeType> nodeType, string name, IConstantNode<ITypeDeclaration> type, IFormula parent) // : this(nodeType, name, type, parent, new INode[] { }) //{ //} protected internal Formula(IConstantNode<NodeType> nodeType, string name, IConstantNode<ITypeDeclaration> type, IFormula parent, params INode[] properties) : this(parent, name, new INode[] { type, parent }.Concat(properties).ToArray()) { }
public static IEqualFormula Equal(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) { return new EqualFormula(left, right, type, method, parent); }
public static IConvertFormula Convert(ITypeDeclaration type, IFormula operand, IMethodDeclaration method, IFormula parent) { return new ConvertFormula(type, operand, method, parent); }
protected internal ConvertFormula(ITypeDeclaration type, IFormula operand, IMethodDeclaration method, IFormula parent) : base(NodeType.Convert, type, operand, method, parent) { }
Formula(IFormula parent, string name, IList<INode> properties) : base(parent, name, new NodeCollection<INode>(properties, parent)) { NodeType = (IConstantNode<NodeType>)properties[0]; Type = (IConstantNode<ITypeDeclaration>)properties[1]; }
public static IMethodCallFormula Call(IFormula instance, IMethodDeclaration method, ReadOnlyCollection<IFormula> arguments, ITypeDeclaration type, IFormula parent) { return new MethodCallFormula(instance, method, arguments, type, parent); }
protected Formula(NodeType nodeType, ITypeDeclaration type, IFormula parent) { NodeType = nodeType; Type = type; Parent = parent; }
public static IAssignFormula Assign(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) { return new AssignFormula(left, right, type, method, parent); }
public static IVariableFormula Variable(ITypeDeclaration type, string name, IFormula parent) { return new VariableFormula(type, name, parent); }
protected internal ExclusiveOrFormula(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) : base(NodeType.ExclusiveOr, left, right, type, method, parent) { }
public NeighbourFinder(IFormula formula) { currentFormula = formula; }
protected internal VariableFormula(ITypeDeclaration type, string name, IFormula parent) : base(NodeType.Variable, type, parent) { Name = name; }
public static IConditionalFormula Condition(IFormula test, IFormula ifTrue, IFormula ifFalse, ITypeDeclaration type, IFormula parent) { return new ConditionalFormula(test, ifTrue, ifFalse, type, parent); }
protected internal ReturnFormula(IFormula @object, ITypeDeclaration type, IFormula parent) : base(NodeType.Return, type, parent) { Object = @object; }
public static IConstantFormula Constant(object value, ITypeDeclaration type, IFormula parent) { return new ConstantFormula(value, type, parent); }
public static IMultiplyFormula Multiply(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) { return new MultiplyFormula(left, right, type, method, parent); }
public static IExclusiveOrFormula ExclusiveOr(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) { return new ExclusiveOrFormula(left, right, type, method, parent); }
protected internal MultiplyFormula(IFormula left, IFormula right, ITypeDeclaration type, IMethodDeclaration method, IFormula parent) : base(NodeType.Multiply, left, right, type, method, parent) { }
public static IReturnFormula Return(IFormula formula, ITypeDeclaration type, IFormula parent) { return new ReturnFormula(formula, type, parent); }
protected abstract IFormula Pin(IFormula parent, IList<INode> properties);
public static ITypeAsFormula TypeAs(ITypeDeclaration type, IFormula operand, IMethodDeclaration method, IFormula parent) { return new TypeAsFormula(type, operand, method, parent); }