/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IProcessingResourceSpecification activeResourceSpecifications_ResourceContainerCasted = item.As <IProcessingResourceSpecification>(); if ((activeResourceSpecifications_ResourceContainerCasted != null)) { this._parent.ActiveResourceSpecifications_ResourceContainer.Add(activeResourceSpecifications_ResourceContainerCasted); } if ((this._parent.ResourceEnvironment_ResourceContainer == null)) { IResourceEnvironment resourceEnvironment_ResourceContainerCasted = item.As <IResourceEnvironment>(); if ((resourceEnvironment_ResourceContainerCasted != null)) { this._parent.ResourceEnvironment_ResourceContainer = resourceEnvironment_ResourceContainerCasted; return; } } IResourceContainer nestedResourceContainers__ResourceContainerCasted = item.As <IResourceContainer>(); if ((nestedResourceContainers__ResourceContainerCasted != null)) { this._parent.NestedResourceContainers__ResourceContainer.Add(nestedResourceContainers__ResourceContainerCasted); } if ((this._parent.ParentResourceContainer__ResourceContainer == null)) { IResourceContainer parentResourceContainer__ResourceContainerCasted = item.As <IResourceContainer>(); if ((parentResourceContainer__ResourceContainerCasted != null)) { this._parent.ParentResourceContainer__ResourceContainer = parentResourceContainer__ResourceContainerCasted; return; } } }
/// <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.TargetResourceEnvironment_Allocation == null)) { IResourceEnvironment targetResourceEnvironment_AllocationCasted = item.As <IResourceEnvironment>(); if ((targetResourceEnvironment_AllocationCasted != null)) { this._parent.TargetResourceEnvironment_Allocation = targetResourceEnvironment_AllocationCasted; return; } } if ((this._parent.System_Allocation == null)) { ISystem0 system_AllocationCasted = item.As <ISystem0>(); if ((system_AllocationCasted != null)) { this._parent.System_Allocation = system_AllocationCasted; return; } } IAllocationContext allocationContexts_AllocationCasted = item.As <IAllocationContext>(); if ((allocationContexts_AllocationCasted != null)) { this._parent.AllocationContexts_Allocation.Add(allocationContexts_AllocationCasted); } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IResourceContainer connectedResourceContainers_LinkingResourceCasted = item.As <IResourceContainer>(); if ((connectedResourceContainers_LinkingResourceCasted != null)) { this._parent.ConnectedResourceContainers_LinkingResource.Add(connectedResourceContainers_LinkingResourceCasted); } if ((this._parent.CommunicationLinkResourceSpecifications_LinkingResource == null)) { ICommunicationLinkResourceSpecification communicationLinkResourceSpecifications_LinkingResourceCasted = item.As <ICommunicationLinkResourceSpecification>(); if ((communicationLinkResourceSpecifications_LinkingResourceCasted != null)) { this._parent.CommunicationLinkResourceSpecifications_LinkingResource = communicationLinkResourceSpecifications_LinkingResourceCasted; return; } } if ((this._parent.ResourceEnvironment_LinkingResource == null)) { IResourceEnvironment resourceEnvironment_LinkingResourceCasted = item.As <IResourceEnvironment>(); if ((resourceEnvironment_LinkingResourceCasted != null)) { this._parent.ResourceEnvironment_LinkingResource = resourceEnvironment_LinkingResourceCasted; return; } } }
/// <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(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent) { IResourceEnvironment oldEnvironment = ModelHelper.CastAs <IResourceEnvironment>(oldParent); IResourceEnvironment newEnvironment = ModelHelper.CastAs <IResourceEnvironment>(newParent); ValueChangedEventArgs e = new ValueChangedEventArgs(oldEnvironment, newEnvironment); this.OnEnvironmentChanging(e); this.OnPropertyChanging("Environment", e, _environmentReference); }
/// <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) { IResourceEnvironment oldResourceEnvironment_LinkingResource = ModelHelper.CastAs <IResourceEnvironment>(oldParent); IResourceEnvironment newResourceEnvironment_LinkingResource = ModelHelper.CastAs <IResourceEnvironment>(newParent); ValueChangedEventArgs e = new ValueChangedEventArgs(oldResourceEnvironment_LinkingResource, newResourceEnvironment_LinkingResource); this.OnResourceEnvironment_LinkingResourceChanging(e); this.OnPropertyChanging("ResourceEnvironment_LinkingResource", e, _resourceEnvironment_LinkingResourceReference); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { if ((this._parent.Environment == null)) { IResourceEnvironment environmentCasted = item.As <IResourceEnvironment>(); if ((environmentCasted != null)) { this._parent.Environment = environmentCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { if ((this._parent.Environment == null)) { IResourceEnvironment environmentCasted = item.As <IResourceEnvironment>(); if ((environmentCasted != null)) { this._parent.Environment = environmentCasted; return; } } IResourceContainer connectsCasted = item.As <IResourceContainer>(); if ((connectsCasted != null)) { this._parent.Connects.Add(connectsCasted); } }
/// <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(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent) { IResourceEnvironment oldEnvironment = ModelHelper.CastAs <IResourceEnvironment>(oldParent); IResourceEnvironment newEnvironment = ModelHelper.CastAs <IResourceEnvironment>(newParent); if ((oldEnvironment != null)) { oldEnvironment.Container.Remove(this); } if ((newEnvironment != null)) { newEnvironment.Container.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldEnvironment, newEnvironment); this.OnEnvironmentChanged(e); this.OnPropertyChanged("Environment", e, _environmentReference); base.OnParentChanged(newParent, oldParent); }
/// <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) { IResourceEnvironment oldResourceEnvironment_LinkingResource = ModelHelper.CastAs <IResourceEnvironment>(oldParent); IResourceEnvironment newResourceEnvironment_LinkingResource = ModelHelper.CastAs <IResourceEnvironment>(newParent); if ((oldResourceEnvironment_LinkingResource != null)) { oldResourceEnvironment_LinkingResource.LinkingResources__ResourceEnvironment.Remove(this); } if ((newResourceEnvironment_LinkingResource != null)) { newResourceEnvironment_LinkingResource.LinkingResources__ResourceEnvironment.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldResourceEnvironment_LinkingResource, newResourceEnvironment_LinkingResource); this.OnResourceEnvironment_LinkingResourceChanged(e); this.OnPropertyChanged("ResourceEnvironment_LinkingResource", e, _resourceEnvironment_LinkingResourceReference); base.OnParentChanged(newParent, oldParent); }
public static void PerformChanges(IRepository pcmRepository, ISystem0 system, IResourceEnvironment resourceEnvironment, Allocation allocation, Model model, string target) { var last = false; var i = 0; ModelChangeRecorder recorder = null; StartNextRecorder(model, target, last, ref i, ref recorder); var container = new ResourceContainer { Id = Guid.NewGuid().ToString(), EntityName = "A random new container", }; resourceEnvironment.ResourceContainer_ResourceEnvironment.Add(container); StartNextRecorder(model, target, last, ref i, ref recorder); // next, we allocate an assembly context to this container var allocationCtx = allocation.AllocationContexts_Allocation[0]; var oldContainer = allocationCtx.ResourceContainer_AllocationContext; allocationCtx.ResourceContainer_AllocationContext = container; StartNextRecorder(model, target, last, ref i, ref recorder); // to repair the situation, we create a link between the old container and the new one var link = new LinkingResource { Id = Guid.NewGuid().ToString(), EntityName = "SnailConnection" }; link.ConnectedResourceContainers_LinkingResource.Add(oldContainer); link.ConnectedResourceContainers_LinkingResource.Add(container); resourceEnvironment.LinkingResources__ResourceEnvironment.Add(link); StartNextRecorder(model, target, last, ref i, ref recorder); // create a new dummy interface var dummyInterface = new OperationInterface { Id = Guid.NewGuid().ToString(), EntityName = "Foobar" }; pcmRepository.Interfaces__Repository.Add(dummyInterface); StartNextRecorder(model, target, last, ref i, ref recorder); // create a dummy component var dummyComponent = new BasicComponent { Id = Guid.NewGuid().ToString(), EntityName = "Dummy" }; var realAssembly = allocationCtx.AssemblyContext_AllocationContext; var realComponent = realAssembly.EncapsulatedComponent__AssemblyContext; var realProvided = realComponent.ProvidedRoles_InterfaceProvidingEntity[0] as IOperationProvidedRole; var realInterface = realProvided.ProvidedInterface__OperationProvidedRole; var requireReal = new OperationRequiredRole { Id = Guid.NewGuid().ToString(), EntityName = "Required", RequiredInterface__OperationRequiredRole = realInterface }; dummyComponent.RequiredRoles_InterfaceRequiringEntity.Add(requireReal); var requireFake = new OperationRequiredRole { Id = Guid.NewGuid().ToString(), EntityName = "Fake", RequiredInterface__OperationRequiredRole = dummyInterface }; dummyComponent.RequiredRoles_InterfaceRequiringEntity.Add(requireFake); pcmRepository.Components__Repository.Add(dummyComponent); StartNextRecorder(model, target, last, ref i, ref recorder); // create an assembly for the dummy var dummyAssembly = new AssemblyContext { Id = Guid.NewGuid().ToString(), EntityName = "DummyAssembly", EncapsulatedComponent__AssemblyContext = dummyComponent }; system.AssemblyContexts__ComposedStructure.Add(dummyAssembly); // create a connector from the dummy to a real assembly var connector = new AssemblyConnector { Id = Guid.NewGuid().ToString(), EntityName = "A connector", ProvidedRole_AssemblyConnector = realProvided, ProvidingAssemblyContext_AssemblyConnector = realAssembly, RequiredRole_AssemblyConnector = requireFake, RequiringAssemblyContext_AssemblyConnector = dummyAssembly }; system.Connectors__ComposedStructure.Add(connector); StartNextRecorder(model, target, last, ref i, ref recorder); // fix the connector connector.RequiredRole_AssemblyConnector = requireReal; last = true; StartNextRecorder(model, target, last, ref i, ref recorder); }