Example #1
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                if ((this._parent.EventGroup__EventChannel == null))
                {
                    IEventGroup eventGroup__EventChannelCasted = item.As <IEventGroup>();
                    if ((eventGroup__EventChannelCasted != null))
                    {
                        this._parent.EventGroup__EventChannel = eventGroup__EventChannelCasted;
                        return;
                    }
                }
                IEventChannelSourceConnector eventChannelSourceConnector__EventChannelCasted = item.As <IEventChannelSourceConnector>();

                if ((eventChannelSourceConnector__EventChannelCasted != null))
                {
                    this._parent.EventChannelSourceConnector__EventChannel.Add(eventChannelSourceConnector__EventChannelCasted);
                }
                IEventChannelSinkConnector eventChannelSinkConnector__EventChannelCasted = item.As <IEventChannelSinkConnector>();

                if ((eventChannelSinkConnector__EventChannelCasted != null))
                {
                    this._parent.EventChannelSinkConnector__EventChannel.Add(eventChannelSinkConnector__EventChannelCasted);
                }
                if ((this._parent.ParentStructure__EventChannel == null))
                {
                    IComposedStructure parentStructure__EventChannelCasted = item.As <IComposedStructure>();
                    if ((parentStructure__EventChannelCasted != null))
                    {
                        this._parent.ParentStructure__EventChannel = parentStructure__EventChannelCasted;
                        return;
                    }
                }
            }
Example #2
0
        /// <summary>
        /// Gets called when the parent model element of the current model element is about to change
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanging(IModelElement newParent, IModelElement oldParent)
        {
            IEventGroup           oldEventGroup__EventType = ModelHelper.CastAs <IEventGroup>(oldParent);
            IEventGroup           newEventGroup__EventType = ModelHelper.CastAs <IEventGroup>(newParent);
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldEventGroup__EventType, newEventGroup__EventType);

            this.OnEventGroup__EventTypeChanging(e);
            this.OnPropertyChanging("EventGroup__EventType", e, _eventGroup__EventTypeReference);
        }
Example #3
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.EventGroup__SinkRole == null))
     {
         IEventGroup eventGroup__SinkRoleCasted = item.As <IEventGroup>();
         if ((eventGroup__SinkRoleCasted != null))
         {
             this._parent.EventGroup__SinkRole = eventGroup__SinkRoleCasted;
             return;
         }
     }
 }
Example #4
0
        public void ReplaceMoleculeKeywordInNonApplicationEventGroup(IEventGroup eventGroup, IMoleculeBuildingBlock molecules)
        {
            if (!molecules.AllFloating().Any())
            {
                return;
            }

            var keywordReplacer = new KeywordReplacerCollection();

            addMoleculeReplacersTo(keywordReplacer, molecules.AllFloating().First().Name);

            replaceInEventGroup(eventGroup, keywordReplacer);
        }
Example #5
0
        public void ReplaceIn(IEventGroup eventGroup, IContainer rootContainer, IEventGroupBuilder eventGroupBuilder, IMoleculeBuildingBlock molecules)
        {
            var keywordReplacer = new KeywordReplacerCollection();

            addCommonModelReplacersTo(keywordReplacer, rootContainer);

            var applicationBuilder = eventGroupBuilder as IApplicationBuilder;

            if (applicationBuilder != null)
            {
                addMoleculeReplacersTo(keywordReplacer, applicationBuilder.MoleculeName);
            }

            replaceInEventGroup(eventGroup, keywordReplacer);
        }
        private void createApplication(IApplicationBuilder applicationBuilder, IEventGroup eventGroup, IBuildConfiguration buildConfiguration)
        {
            var molecules = buildConfiguration.Molecules;

            //---- add molecule amounts
            foreach (var appMolecule in applicationBuilder.Molecules)
            {
                var molecule = _moleculeMapper.MapFrom(molecules[applicationBuilder.MoleculeName], buildConfiguration);
                molecule.Formula = _formulaMapper.MapFrom(appMolecule.Formula, buildConfiguration);

                //get container for the molecule
                var moleculeContainer = appMolecule.RelativeContainerPath.Resolve <IContainer>(eventGroup);
                moleculeContainer.Add(molecule);

                addVolumeParameterTo(moleculeContainer);
            }
        }
Example #7
0
        protected override void Context()
        {
            base.Context();
            _model        = new Model();
            _model.Root   = new Container().WithName("root");
            _applications = new Container().WithName("EG");
            _organism     = new Container().WithName("Org");
            _model.Root.AddChildren(_applications, _organism);
            _simApp = new EventGroup().WithName("App");
            _applications.Add(_simApp);
            _globalApp = new EventGroup().WithName("App").WithParentContainer(_model.Root);

            _simulation = new ModelCoreSimulation {
                BuildConfiguration = new BuildConfiguration(), Model = _model
            };

            _simulation.BuildConfiguration.EventGroups = _eventGroubBuildingBlock;
        }
Example #8
0
        /// <summary>
        /// Gets called when the parent model element of the current model element changes
        /// </summary>
        /// <param name="oldParent">The old parent model element</param>
        /// <param name="newParent">The new parent model element</param>
        protected override void OnParentChanged(IModelElement newParent, IModelElement oldParent)
        {
            IEventGroup oldEventGroup__EventType = ModelHelper.CastAs <IEventGroup>(oldParent);
            IEventGroup newEventGroup__EventType = ModelHelper.CastAs <IEventGroup>(newParent);

            if ((oldEventGroup__EventType != null))
            {
                oldEventGroup__EventType.EventTypes__EventGroup.Remove(this);
            }
            if ((newEventGroup__EventType != null))
            {
                newEventGroup__EventType.EventTypes__EventGroup.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldEventGroup__EventType, newEventGroup__EventType);

            this.OnEventGroup__EventTypeChanged(e);
            this.OnPropertyChanged("EventGroup__EventType", e, _eventGroup__EventTypeReference);
            base.OnParentChanged(newParent, oldParent);
        }
Example #9
0
        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));
                }
            }
        }
Example #10
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Parameter__EventType == null))
     {
         IParameter parameter__EventTypeCasted = item.As <IParameter>();
         if ((parameter__EventTypeCasted != null))
         {
             this._parent.Parameter__EventType = parameter__EventTypeCasted;
             return;
         }
     }
     if ((this._parent.EventGroup__EventType == null))
     {
         IEventGroup eventGroup__EventTypeCasted = item.As <IEventGroup>();
         if ((eventGroup__EventTypeCasted != null))
         {
             this._parent.EventGroup__EventType = eventGroup__EventTypeCasted;
             return;
         }
     }
 }
        private void addApplicationTransports(IApplicationBuilder applicationBuilder, IEventGroup eventGroup)
        {
            var allEventGroupParentChildContainers = eventGroup.GetAllContainersAndSelf <IContainer>().ToEntityDescriptorMapList();

            foreach (var appTransport in applicationBuilder.Transports)
            {
                var transportBuilder = appTransport;
                if (!_applicationTransportTargetContainerCache.Contains(transportBuilder.TargetCriteria))
                {
                    _applicationTransportTargetContainerCache.Add(appTransport.TargetCriteria, _allModelContainerDescriptors.AllSatisfiedBy(transportBuilder.TargetCriteria));
                }

                addApplicationTransportToModel(transportBuilder, allEventGroupParentChildContainers, applicationBuilder.MoleculeName);
            }
        }
Example #12
0
 private void replaceInEventGroup(IEventGroup eventGroup, KeywordReplacerCollection keywordReplacer)
 {
     eventGroup.GetAllChildren <IUsingFormula>().Each(keywordReplacer.ReplaceIn);
     eventGroup.GetAllChildren <IEventAssignment>().Select(x => x.ObjectPath).Each(keywordReplacer.ReplaceIn);
 }