private void addContainerVolumeParameter(IMoBiContext context) { var volume = _container.GetSingleChildByName <IParameter>(Constants.Parameters.VOLUME); //switch from physical to logical. If volume was created here, this command is an inverse and volume should be removed if (_newContainerMode == ContainerMode.Logical) { if (_volumeParameterCreatedHere && volume != null) { _container.RemoveChild(volume); context.Unregister(volume); context.PublishEvent(new RemovedEvent(volume, _container)); } } //we switched from Logical to physical. Add volume parameter if not available else { if (volume != null) { return; } var parameterFactory = context.Resolve <IParameterFactory>(); volume = parameterFactory.CreateVolumeParameter(); _container.Add(volume); context.Register(volume); _volumeParameterCreatedHere = true; context.PublishEvent(new AddedEvent <IParameter>(volume, _container)); } }
protected override void ExecuteWith(IMoBiContext context) { base.ExecuteWith(context); Description = AppConstants.Commands.RemoveFromDescription(ObjectType, _itemToRemove.Name, _parent.Name, context.TypeFor(_buildingBlock), _buildingBlock.Name); RemoveFrom(_itemToRemove, _parent, context); context.Unregister(_itemToRemove); context.PublishEvent(new RemovedEvent(_itemToRemove, _parent)); }
protected override void ExecuteWith(IMoBiContext context) { var project = context.CurrentProject; removeFromProject(project); context.Unregister(_buildingBlock); _serializationStream = context.Serialize(_buildingBlock); context.PublishEvent(new RemovedEvent(_buildingBlock, project)); }