public TankInstance(IRepository repository, TankEntity tank, TankInstanceConfigurationInfo configInfo) : base(tank.ToElement()) { this._repository = repository; this._tank = tank; this.Element.Name = "data"; this.Element.ExistedElement("crews").Remove(); this.Element.ExistedElement("chassis").Remove(); this.Element.ExistedElement("turrets").Remove(); this.Element.ExistedElement("engines").Remove(); this.Element.ExistedElement("radios").Remove(); var fuelTank = new XElement(this.Element.ExistedElement("fuelTanks").ExistedElement("fuelTank")); this.Element.ExistedElement("fuelTanks").ReplaceWith(fuelTank); _scriptHost = new ScriptHost(); this.TankConfiguration = new TankConfiguration(repository, tank, _scriptHost, configInfo == null ? null : configInfo.TankConfigurationInfo); this.CrewConfiguration = new CrewConfiguration(repository, tank, _scriptHost, configInfo == null ? null : configInfo.CrewConfigurationInfo); this.CustomizationConfiguration = new CustomizationConfiguration(repository, tank, _scriptHost, configInfo == null ? null : configInfo.CustomizationConfigurationInfo); this.Element.Add(_scriptHost.Element); _scriptHost.ElementChanged += OnSubElementChanged; if (configInfo == null) { _tankInstanceConfigurationInfo = new TankInstanceConfigurationInfo { TankConfigurationInfo = this.TankConfiguration.TankConfigurationInfo, CrewConfigurationInfo = this.CrewConfiguration.CrewConfigurationInfo, CustomizationConfigurationInfo = this.CustomizationConfiguration.CustomizationConfigurationInfo }; } else { _tankInstanceConfigurationInfo = configInfo; } }