Ejemplo n.º 1
0
        private void replaceInUsingFormula(IUsingFormula usingFormula, IContainer rootContainer)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);
            keywordReplacer.ReplaceIn(usingFormula);
        }
Ejemplo n.º 2
0
        public void Visit(IMoleculeAmount moleculeAmount)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, _rootContainer);
            addMoleculeReplacersTo(keywordReplacer, moleculeAmount.Name);
            keywordReplacer.ReplaceIn(moleculeAmount);
        }
Ejemplo n.º 3
0
        public void ReplaceIn(IObserver observer, IContainer rootContainer, string moleculeName, INeighborhood neighborhood)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);
            addCommonNeighborhoodReplacersTo(keywordReplacer, neighborhood);
            addMoleculeReplacersTo(keywordReplacer, moleculeName);
            keywordReplacer.ReplaceIn(observer);
        }
Ejemplo n.º 4
0
        public IObjectPath CreateModelPathFor(IObjectPath objectPath, IContainer rootContainer)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);
            var modelPath = objectPath.Clone <IObjectPath>();

            keywordReplacer.ReplaceIn(modelPath);
            return(modelPath);
        }
Ejemplo n.º 5
0
        private void replaceIn(IUsingFormula usingFormula, IContainer rootContainer, string moleculeName)
        {
            if (usingFormula == null)
            {
                return;
            }
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);
            addMoleculeReplacersTo(keywordReplacer, moleculeName);
            keywordReplacer.ReplaceIn(usingFormula);
        }
Ejemplo n.º 6
0
        public void ReplaceInReactionContainer(IContainer reactionContainer, IContainer rootContainer)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);
            var reaction = reactionContainer as IReaction;

            if (reaction != null)
            {
                keywordReplacer.ReplaceIn(reaction);
            }

            replaceInContainer(reactionContainer, rootContainer);
        }
Ejemplo n.º 7
0
        public void ReplaceIn(ITransport realization, IContainer rootContainer, string moleculeName, INeighborhood neighborhood, string transportName, string transporterName)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);
            addMoleculeReplacersTo(keywordReplacer, moleculeName);
            addCommonNeighborhoodReplacersTo(keywordReplacer, neighborhood);

            keywordReplacer.AddReplacement(new KeywordWithPathReplacer(ObjectPathKeywords.SOURCE, _objectPathFactory.CreateAbsoluteObjectPath(realization.SourceAmount.ParentContainer)));
            keywordReplacer.AddReplacement(new KeywordWithPathReplacer(ObjectPathKeywords.TARGET, _objectPathFactory.CreateAbsoluteObjectPath(realization.TargetAmount.ParentContainer)));
            keywordReplacer.AddReplacement(new KeywordWithPathReplacer(ObjectPathKeywords.REALIZATION, new ObjectPath(transportName, realization.Name)));
            keywordReplacer.AddReplacement(new SimpleKeywordReplacer(ObjectPathKeywords.TRANSPORT, transportName));
            keywordReplacer.AddReplacement(new SimpleKeywordReplacer(ObjectPathKeywords.TRANSPORTER, transporterName));
            keywordReplacer.ReplaceIn(realization);
            replaceInContainer(realization, rootContainer);

            //replaceInContainer only replaces standard keywords. Transport specific keywords need to be replaced in all children explicitely
            var transportContainer = realization.ParentContainer ?? realization;

            transportContainer.GetAllChildren <IUsingFormula>().Each(keywordReplacer.ReplaceIn);
        }