public void StartComparison(IObjectBase selectedObject, RelatedItem relatedItem) { if (selectedObject == null) { return; } if (!loadContent(relatedItem)) { return; } var relatedObject = _relatedItemSerializer.Deserialize(relatedItem); _eventPublisher.PublishEvent(new StartComparisonEvent( leftObject: relatedObject, leftCaption: Captions.Journal.CompareRelatedItem(relatedItem.Name), rightObject: selectedObject, rightCaption: Captions.Journal.CompareProjectItem(selectedObject.Name)) ); }
private bool eventGroupBuildingBlockContains(IObjectBase objectBase) { if (_eventGroupBuildingBlock.Equals(objectBase)) { return(true); } var testEntity = objectBase as IEntity; if (testEntity != null) { return(eventGroupContainsEntity(testEntity)); } if (!objectBase.IsAnImplementationOf <ITransportBuilder>()) { return(false); } return(eventGroupContainesTranportBuilder(objectBase)); }
public IEnumerable <SearchResult> SearchIn(IObjectBase searchTarget, IMoBiProject project) { try { _result = new List <SearchResult>(); _allBuildingBlocks = project.AllBuildingBlocks(); _searchExpressionCreated = false; _localVisitor = new LocalSearchVisitor(getSearchExpression()) { CaseSensitiv = CaseSensitiv }; searchTarget.AcceptVisitor(this); return(Result); } finally { _projectItem = null; _localVisitor = null; _allBuildingBlocks = null; } }
public virtual void AddMessage(NotificationType notificationType, IObjectBase invalidObject, string notification, IBuildingBlock buildingBlock = null, IEnumerable <string> details = null) { if (!_messages.Contains(invalidObject)) { var message = new ValidationMessage(notificationType, notification, invalidObject, buildingBlock); addDetailsToMessage(message, details); addMessage(message); } else { var existingNotification = _messages[invalidObject]; if (!existingNotification.Details.Any()) { var oldNotification = existingNotification.Text; existingNotification.Text = Validation.MultipleNotificationsFor(notificationType.ToString(), invalidObject.Name); existingNotification.AddDetail(oldNotification); } existingNotification.AddDetail(notification); addDetailsToMessage(existingNotification, details); } }
public void On_ChangeUsername(PageNames pageName, IObjectBase senderContext, string sourceName, string sourceContent, out PageNames destinationPageName) { if (IsPasswordRequired && !ClearPasswordAndCompare()) { IsPasswordInvalidError = true; NotifyPropertyChanged(nameof(IsPasswordInvalidError)); destinationPageName = PageNames.CurrentPage; } else if (string.IsNullOrEmpty(NewUsername) || SignedInAccount == null) { destinationPageName = PageNames.CurrentPage; } else { ((Account)SignedInAccount).ChangeUsername(NewUsername); destinationPageName = PageNames.profilePage; } }
private bool shouldShowNotifiction(IObjectBase entityToValidate, string notification) { if (_userSettings.ShowPKSimDimensionProblemWarnings) { return(true); } if (!_hiddenNotifications.Keys.Contains(entityToValidate.Name)) { return(true); } var messageEnd = _hiddenNotifications[entityToValidate.Name]; if (notification.EndsWith(messageEnd)) { return(false); } return(true); }
public IEnumerable <SearchResult> StartSearch(SearchOptions options, IObjectBase localSearchTarget) { if (options.Expression.IsNullOrEmpty()) { return(Enumerable.Empty <SearchResult>()); } _searchVisitor.SearchFor = options.Expression; _searchVisitor.RegExSearch = options.RegEx; _searchVisitor.WholeWord = options.WholeWord; _searchVisitor.CaseSensitive = options.CaseSensitive; var project = _context.CurrentProject; switch (options.Scope) { case SearchScope.Project: return(_searchVisitor.SearchIn(project, project)); case SearchScope.AllOfSameType: if (localSearchTarget == null) { return(Enumerable.Empty <SearchResult>()); } return(searchInAllOfSameType(localSearchTarget.GetType(), project)); case SearchScope.Local: if (localSearchTarget == null) { return(Enumerable.Empty <SearchResult>()); } return(_searchVisitor.SearchIn(localSearchTarget, project)); default: throw new ArgumentOutOfRangeException(nameof(options.Scope)); } }
public IMoBiCommand Rename(IObjectBase objectBase, IEnumerable <string> alreadyUsedNames, IBuildingBlock buildingBlock) { var unallowedNames = new List <string>(alreadyUsedNames); unallowedNames.AddRange(AppConstants.UnallowedNames); var objectName = _objectTypeResolver.TypeFor(objectBase); string newName; using (var renameObjectPresenter = _applicationController.Start <IRenameObjectPresenter>()) { newName = renameObjectPresenter.NewNameFrom(objectBase, unallowedNames); } if (string.IsNullOrEmpty(newName)) { return(new MoBiEmptyCommand()); } var commandCollector = new MoBiMacroCommand { CommandType = AppConstants.Commands.RenameCommand, ObjectType = objectName, Description = AppConstants.Commands.RenameDescription(objectBase, newName) }; if (CheckUsagesFor(newName, objectBase.Name, objectBase, commandCollector)) { commandCollector.AddCommand(new RenameObjectBaseCommand(objectBase, newName, buildingBlock) { ObjectType = objectName }); } commandCollector.Run(_context); return(commandCollector); }
protected virtual bool DecoupleObjectBase(IObjectBase objectBase, bool recursive) { if (objectBase.GetType() == typeof(Container)) { var container = objectBase.DowncastTo <IContainer>(); if (recursive) { foreach (var child in container.Children) { DecoupleObjectBase(child, recursive: true); } } return(Decouple <IContainer, IContainerNode>(container)); } if (objectBase.IsAnImplementationOf <INeighborhoodBase>()) { return(Decouple <INeighborhoodBase, TNeighborhoodNode>(objectBase.DowncastTo <INeighborhoodBase>())); } return(false); // not removed by this implementation }
protected override bool RemoveObjectBase(IObjectBase objectBase, bool recursive) { if (RemoveAndDecoupleNode <IMoleculeAmount, MoleculeNode>(objectBase as IMoleculeAmount)) { return(true); } if (RemoveAndDecoupleNode <IObserver, ObserverNode>(objectBase as IObserver)) { return(true); } if (RemoveAndDecoupleNode <IReaction, ReactionNode>(objectBase as IReaction)) { return(true); } if (base.RemoveObjectBase(objectBase, recursive)) { return(true); } return(false); // not removed by this implementation }
protected override IBaseNode AddObjectBase(IContainerBase parent, IObjectBase objectBase, bool recursive, bool coupleAll) { IElementBaseNode eNode = AddAndCoupleNode <IMoleculeAmount, MoleculeNode>(parent, objectBase as IMoleculeAmount, coupleAll); if (eNode == null) { eNode = AddAndCoupleNode <IObserver, ObserverNode>(parent, objectBase as IObserver, coupleAll); } if (eNode == null) { eNode = AddAndCoupleNode <IReaction, ReactionNode>(parent, objectBase as IReaction, coupleAll); } if (eNode != null) { eNode.CanLink = false; return(eNode); } return(base.AddObjectBase(parent, objectBase, recursive, coupleAll)); }
private void setupEditPresenterFor(IObjectBase objectToEdit, IParameter parameter = null) { if (objectToEdit == null) { _view.SetEditView(null); return; } switch (objectToEdit) { case IApplicationMoleculeBuilder applicationMoleculeBuilder: setupEditPresenterFor(applicationMoleculeBuilder.ParentContainer); return; case IApplicationBuilder applicationBuilder: showPresenter(_editApplicationBuilderPresenter, applicationBuilder, parameter); return; case IEventGroupBuilder eventGroupBuilder: showPresenter(_editEventGroupPresenter, eventGroupBuilder, parameter); return; case IEventBuilder eventBuilder: showPresenter(_editEventBuilderPresenter, eventBuilder, parameter); return; case ITransportBuilder transportBuilder: showPresenter(_editApplicationTransportBuilderPresenter, transportBuilder, parameter); return; case IContainer container: showPresenter(_editContainerPresenter, container, parameter); return; default: throw new MoBiException(AppConstants.Exceptions.NoEditPresenterFoundFor(objectToEdit)); } }
protected override void Context() { base.Context(); _project = A.Fake <IProject>(); _project.FilePath = "ABC"; _relatedObject = A.Fake <IObjectBase>() .WithName("Toto") .WithIcon("Icon"); A.CallTo(() => _relatedItemTypeRetriever.TypeFor(_relatedObject)).Returns("MyType"); _data = new byte[] { 15, 05, 24 }; A.CallTo(() => _relatedItemSerializer.Serialize(_relatedObject)).Returns(_data); A.CallTo(() => _relatedItemDescriptionCreator.DescriptionFor(_relatedObject)).Returns("DESC"); A.CallTo(() => _applicationConfiguration.FullVersion).Returns("123"); A.CallTo(() => _applicationConfiguration.Product).Returns(Origins.PKSim); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); }
public void On_SignUp(PageNames pageName, IObjectBase senderContext, string sourceName, string sourceContent, out PageNames destinationPageName) { Account NewAccount; SignInError Error = ((AccountManager)GetAccountManager).TryAddAccount(Email, SignInMethod, Name, Password, out NewAccount); switch (Error) { case SignInError.None: break; default: case SignInError.NameAlreadyInUse: NameError = true; NotifyPropertyChanged(nameof(NameError)); SignUpError = true; NotifyPropertyChanged(nameof(SignUpError)); destinationPageName = PageNames.CurrentPage; return; } destinationPageName = PageNames.startPage; }
/// <summary> /// Creates the path from entity. /// </summary> /// <param name="objectBase">The object base that should be referenced</param> /// <param name="shouldCreateAbsolutePaths">if set to <c>true</c> should create absolute paths otherwise relative paths are created.</param> /// <param name="refObject">The object from which the path is created.</param> /// <param name="editedObject"></param> /// <returns> the dto Object for the reference</returns> public virtual ReferenceDTO CreatePathsFromEntity(IObjectBase objectBase, bool shouldCreateAbsolutePaths, IEntity refObject, IUsingFormula editedObject) { var dto = new ReferenceDTO(); if (!objectBase.IsAnImplementationOf <IFormulaUsable>()) { return(null); } var formulaUseable = objectBase.DowncastTo <IFormulaUsable>(); if (isGlobal(objectBase)) { // This a global parameters that we always use as absolute paths dto.Path = CreateAlwaysAbsolutePaths(objectBase, formulaUseable); } else { // local reaction and molecule properties are always referenced local. if (formulaUseable.IsAtReaction() || formulaUseable.IsAtMolecule()) { shouldCreateAbsolutePaths = false; } dto.Path = shouldCreateAbsolutePaths ? CreateAbsolutePath(formulaUseable) : CreateRelativePath(formulaUseable, refObject, editedObject); } var parameter = formulaUseable as IParameter; if (parameter == null) { return(dto); } dto.BuildMode = parameter.BuildMode; updateReferenceForTransportMoleculeContainer(dto, parameter, shouldCreateAbsolutePaths); return(dto); }
// signature is necessary for use as argument in RegisterUpdateMethod public void UpdateReactionBuilder(IObjectBase reactionAsObjectBase, IBaseNode reactionNodeAsBaseNode) { var reactionBuilder = reactionAsObjectBase.DowncastTo <IReactionBuilder>(); var reactionNode = reactionNodeAsBaseNode.DowncastTo <ReactionNode>(); reactionNode.ClearLinks(); foreach (var rpb in reactionBuilder.Educts) { createReactionLink(ReactionLinkType.Educt, reactionNode, getMoleculeNode(rpb.MoleculeName, reactionNode.Location)); } foreach (var rpb in reactionBuilder.Products) { createReactionLink(ReactionLinkType.Product, reactionNode, getMoleculeNode(rpb.MoleculeName, reactionNode.Location)); } foreach (var modifierName in reactionBuilder.ModifierNames) { createReactionLink(ReactionLinkType.Modifier, reactionNode, getMoleculeNode(modifierName, reactionNode.Location)); } reactionNode.SetColorFrom(DiagramOptions.DiagramColors); }
private void updateObserver(IObjectBase observerAsEntity, IBaseNode observerNodeAsBaseNode) { var observer = observerAsEntity.DowncastTo <IObserver>(); var observerNode = observerNodeAsBaseNode.DowncastTo <ObserverNode>(); observerNode.ClearLinks(); foreach (var oRef in observer.Formula.ObjectReferences) { var refId = oRef.Object.Id; var refParentId = oRef.Object.ParentContainer.Id; var moleculeNode = DiagramModel.GetNode <MoleculeNode>(refId); // if object reference is not molecule amount itself, it could be a child of molecule amount, e.g. a concentration if (moleculeNode == null) { moleculeNode = DiagramModel.GetNode <MoleculeNode>(refParentId); } if (moleculeNode != null) { createObserverLink(observerNode, moleculeNode); } } }
public bool ContainsInfoFor(IObjectBase objectBase) { return(_representationInfosCache.Contains(getKey(objectBase))); }
public string DescriptionFor(IObjectBase objectBase) { return(InfoFor(objectBase).Description); }
public string DisplayNameFor(IObjectBase objectBase) { return(InfoFor(objectBase).DisplayName); }
private string getKey(IObjectBase objectBase) { return(getKey(_representationObjectTypeMapper.MapFrom(objectBase.GetType()), objectBase.Name)); }
private void mapObjectBase <T>(ObjectBaseMetaData <T> metaData, IObjectBase objectBase) where T : ObjectBaseMetaData <T> { metaData.Id = objectBase.Id; metaData.Name = objectBase.Name; metaData.Description = objectBase.Description; }
private void addValidationMessage(NotificationType type, IObjectBase objectBase, string message) { _validationResult.AddMessage(type, objectBase, message); }
private void addRuleToValidation(IBusinessRule rule, IObjectBase objectBase) { addValidationMessage(NotificationType.Error, objectBase, rule.Description); }
public override void RestoreExecutionData(IMoBiContext context) { base.RestoreExecutionData(context); _objectBase = context.Get <IObjectBase>(ObjectId); }
public void Add(IObjectBase obj) { _objLines.Add(obj); }
/// <summary> /// This constructor should be used to get an instance to serializable object. This object should be used in /// serialization. /// </summary> /// <param name="objectBase"></param> public AbstractJsonSerializer(IObjectBase objectBase) { this.objectBase = objectBase; }
public IReadOnlyList <ITreeNode> GetNodes(IObjectBase objectBase) { return(containsNodeWithId(objectBase.Id).ToList()); }
private string displayFor(IObjectBase objectBase) => _representationInfoRepository.DisplayNameFor(objectBase);
private IEnumerable <IObjectBaseDTO> dummyLocalParametersUnder(IObjectBase parent, IContainer container, IObjectBaseDTO parentDTO) { return(localParametersUnder(container).Select(x => _dummyParameterDTOMapper.MapFrom(x, container, parentDTO))); }
/// <summary> /// add item to clipboard. Do not erase previous ones /// </summary> public void Add(IObjectBase pastedObject) { _pastedObjects.Add(pastedObject); }
protected override void Context() { base.Context(); _leftObject = A.Fake <IObjectBase>(); _rightObject = A.Fake <IObjectBase>(); }
public MockJsonSerializer(IObjectBase objectBase) : base(objectBase) { }