protected void refreshModel() { if (!string.IsNullOrEmpty(this.Filename)) { string key = string.Format("InstanceSystem{0}:{1}+{2}", (this.EnableAlpha ? "Alpha" : ""), this.Filename.Value, this.InstanceKey.Value); Entity world = Lemma.Factories.WorldFactory.Instance; ModelInstanceSystem newModel = this.EnableAlpha ? world.Get <ModelInstanceSystemAlpha>(key) : world.Get <ModelInstanceSystem>(key); bool foundExistingModel = newModel != null; if (!foundExistingModel) { newModel = this.EnableAlpha ? new ModelInstanceSystemAlpha() : new ModelInstanceSystem(); newModel.Filename.Value = this.Filename; newModel.Key = key; world.Add(key, newModel); } if (newModel != this.model) { this.IsFirstInstance = !foundExistingModel; newModel.Add(this); if (this.model != null) { this.model.Remove(this); } this.model = newModel; this.parameters.Clear(); } this.FullInstanceKey.Value = key; } }
public override void delete() { base.delete(); if (this.model != null) { this.model.Remove(this); this.model = null; } }