コード例 #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)
            {
                IAllocationContext allocationContextsCasted = item.As <IAllocationContext>();

                if ((allocationContextsCasted != null))
                {
                    this._parent.AllocationContexts.Add(allocationContextsCasted);
                }
                if ((this._parent.AllocatedSystem == null))
                {
                    ISystem0 allocatedSystemCasted = item.As <ISystem0>();
                    if ((allocatedSystemCasted != null))
                    {
                        this._parent.AllocatedSystem = allocatedSystemCasted;
                        return;
                    }
                }
                if ((this._parent.Environment == null))
                {
                    IEnvironment environmentCasted = item.As <IEnvironment>();
                    if ((environmentCasted != null))
                    {
                        this._parent.Environment = environmentCasted;
                        return;
                    }
                }
            }
コード例 #2
0
ファイル: Allocation.cs プロジェクト: wasowski/NMF
            /// <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);
                }
            }
コード例 #3
0
ファイル: QoSAnnotations.cs プロジェクト: wasowski/NMF
        /// <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)
        {
            ISystem0 oldSystem_QoSAnnotations = ModelHelper.CastAs <ISystem0>(oldParent);
            ISystem0 newSystem_QoSAnnotations = ModelHelper.CastAs <ISystem0>(newParent);
            ValueChangedEventArgs e           = new ValueChangedEventArgs(oldSystem_QoSAnnotations, newSystem_QoSAnnotations);

            this.OnSystem_QoSAnnotationsChanging(e);
            this.OnPropertyChanging("System_QoSAnnotations", e, _system_QoSAnnotationsReference);
        }
コード例 #4
0
ファイル: QoSAnnotations.cs プロジェクト: wasowski/NMF
        /// <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)
        {
            ISystem0 oldSystem_QoSAnnotations = ModelHelper.CastAs <ISystem0>(oldParent);
            ISystem0 newSystem_QoSAnnotations = ModelHelper.CastAs <ISystem0>(newParent);

            if ((oldSystem_QoSAnnotations != null))
            {
                oldSystem_QoSAnnotations.QosAnnotations_System.Remove(this);
            }
            if ((newSystem_QoSAnnotations != null))
            {
                newSystem_QoSAnnotations.QosAnnotations_System.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldSystem_QoSAnnotations, newSystem_QoSAnnotations);

            this.OnSystem_QoSAnnotationsChanged(e);
            this.OnPropertyChanged("System_QoSAnnotations", e, _system_QoSAnnotationsReference);
            base.OnParentChanged(newParent, oldParent);
        }
コード例 #5
0
ファイル: Root.cs プロジェクト: georghinkel/DeepModelingDemo
 /// <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.System == null))
     {
         ISystem0 systemCasted = item.As <ISystem0>();
         if ((systemCasted != null))
         {
             this._parent.System = systemCasted;
             return;
         }
     }
     if ((this._parent.Repository == null))
     {
         IRepository repositoryCasted = item.As <IRepository>();
         if ((repositoryCasted != null))
         {
             this._parent.Repository = repositoryCasted;
             return;
         }
     }
     if ((this._parent.Allocation == null))
     {
         IAllocation allocationCasted = item.As <IAllocation>();
         if ((allocationCasted != null))
         {
             this._parent.Allocation = allocationCasted;
             return;
         }
     }
     if ((this._parent.Environment == null))
     {
         IEnvironment environmentCasted = item.As <IEnvironment>();
         if ((environmentCasted != null))
         {
             this._parent.Environment = environmentCasted;
             return;
         }
     }
 }
コード例 #6
0
ファイル: QoSAnnotations.cs プロジェクト: wasowski/NMF
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                ISpecifiedOutputParameterAbstraction specifiedOutputParameterAbstractions_QoSAnnotationsCasted = item.As <ISpecifiedOutputParameterAbstraction>();

                if ((specifiedOutputParameterAbstractions_QoSAnnotationsCasted != null))
                {
                    this._parent.SpecifiedOutputParameterAbstractions_QoSAnnotations.Add(specifiedOutputParameterAbstractions_QoSAnnotationsCasted);
                }
                if ((this._parent.System_QoSAnnotations == null))
                {
                    ISystem0 system_QoSAnnotationsCasted = item.As <ISystem0>();
                    if ((system_QoSAnnotationsCasted != null))
                    {
                        this._parent.System_QoSAnnotations = system_QoSAnnotationsCasted;
                        return;
                    }
                }
                ISpecifiedQoSAnnotation specifiedQoSAnnotations_QoSAnnotationsCasted = item.As <ISpecifiedQoSAnnotation>();

                if ((specifiedQoSAnnotations_QoSAnnotationsCasted != null))
                {
                    this._parent.SpecifiedQoSAnnotations_QoSAnnotations.Add(specifiedQoSAnnotations_QoSAnnotationsCasted);
                }
            }
コード例 #7
0
ファイル: PcmChangeGenerator.cs プロジェクト: wasowski/NMF
        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);
        }