Exemplo n.º 1
0
 /// <summary>Undo the command</summary>
 /// <param name="commandHistory">The command history instance</param>
 public void Undo(CommandHistory commandHistory)
 {
     if (this.modelWasRemoved)
     {
         this.parent.Children.Insert(pos, this.modelToDelete as Model);
         this.explorerView.AddChild(Apsim.FullPath(this.parent), nodeDescription, pos);
         Apsim.ClearCache(this.modelToDelete);
     }
 }
Exemplo n.º 2
0
 /// <summary>Move a model from one parent to another.</summary>
 /// <param name="model">The model to move.</param>
 /// <param name="newParent">The new parente for the model.</param>
 public static void Move(IModel model, IModel newParent)
 {
     // Remove old model.
     if (model.Parent.Children.Remove(model as Model))
     {
         // Clear the cache for all models in scope of the model to be moved.
         // The models in scope will be different after the move so we will
         // need to do this again after we move the model.
         Apsim.ClearCache(model);
         newParent.Children.Add(model as Model);
         model.Parent = newParent;
         EnsureNameIsUnique(model);
         Apsim.ClearCache(model);
     }
     else
     {
         throw new Exception("Cannot move model " + model.Name);
     }
 }
Exemplo n.º 3
0
 /// <summary>Renames a new model.</summary>
 /// <param name="model">The model to rename.</param>
 /// <param name="newName">The new name for the model.</param>
 /// <returns>The newly created model.</returns>
 public static void Rename(IModel model, string newName)
 {
     model.Name = newName;
     EnsureNameIsUnique(model);
     Apsim.ClearCache(model);
 }