src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/Rules/EntityType_AddRule.cs
/// <summary>
///     Do the following when a new EntityType shape is created:
///     - Add the new EntityType to the model
/// </summary>
/// <param name="e"></param>
Do the following when a new EntityType shape is created:
Add the new EntityType to the model
Do the following when a new EntityType shape is created : Add the new EntityType to the model
public override void ElementAdded(ElementAddedEventArgs e)
        {
            base.ElementAdded(e);
            var addedEntity = e.ModelElement as EntityType;
            Debug.Assert(addedEntity != null);
            Debug.Assert(addedEntity.EntityDesignerViewModel != null);
            if ((addedEntity != null)
                && (addedEntity.EntityDesignerViewModel != null))
            {
                var viewModel = addedEntity.EntityDesignerViewModel;
                Debug.Assert(viewModel != null);
                var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store);
                Debug.Assert(tx != null, "Make sure we have a Current Active Tx");
                if (tx != null
                    && !tx.IsSerializing)
                {
                    viewModel.EntityTypes.Remove(addedEntity);
                    addedEntity.Delete();
                    ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new EntityTypeAdd());
                }
            }
        }
public override void ElementAdded ( ElementAddedEventArgs e ) { base . ElementAdded ( e ) ; var addedEntity = e . ModelElement as EntityType ; Debug . Assert ( addedEntity != null ) ; Debug . Assert ( addedEntity . EntityDesignerViewModel != null ) ; if ( ( addedEntity != null ) && ( addedEntity . EntityDesignerViewModel != null ) ) { var viewModel = addedEntity . EntityDesignerViewModel ; Debug . Assert ( viewModel != null ) ; var tx = ModelUtils . GetCurrentTx ( e . ModelElement . Store ) ; Debug . Assert ( tx != null , " " ) ; if ( tx != null && ! tx . IsSerializing ) { viewModel . EntityTypes . Remove ( addedEntity ) ; addedEntity . Delete ( ) ; ViewModelChangeContext . GetNewOrExistingContext ( tx ) . ViewModelChanges . Add ( new EntityTypeAdd ( ) ) ; } } }
Do the following when a new EntityType shape is created:
 Add the new EntityType to the model
Do the following when a new EntityType shape is created : Add the new EntityType to the model
// Remove the added DSL EntityType. // When Escher model is updated, there will be a code that will create the EntityType back // create the model change and add it to the current transaction changelist
e
ElementAddedEventArgs
None