private TSimulation createSimulationFor <TSimulation>(string pkmlFileFullPath) where TSimulation : Simulation
        {
            try
            {
                var loadedSim = _simulationTransferLoader.Load(pkmlFileFullPath);
                if (loadedSim == null)
                {
                    return(null);
                }

                var simulation = _simulationFactory.CreateBasedOn <TSimulation>(loadedSim.Simulation);
                _simulationUpdaterAfterDeserialization.UpdateSimulation(simulation);
                return(simulation);
            }
            catch (Exception e)
            {
                throw new PKSimException(PKSimConstants.Error.CouldNotLoadSimulationFromFile(pkmlFileFullPath), e);
            }
        }
        private void updatePropertiesFor <TObject>(TObject deserializedObject, int version)
        {
            //convert object if required
            var conversionHappened = convert(deserializedObject, version);

            var simulation = deserializedObject as Simulation;

            if (simulation != null)
            {
                _simulationUpdater.UpdateSimulation(simulation);
            }

            var individual = deserializedObject as Individual;

            if (individual != null)
            {
                _referenceResolver.ResolveReferencesIn(individual);
            }

            var population = deserializedObject as Population;

            if (population != null)
            {
                _referenceResolver.ResolveReferencesIn(population.FirstIndividual);
            }

            var lazyLoadable = deserializedObject as ILazyLoadable;

            if (lazyLoadable != null)
            {
                lazyLoadable.IsLoaded = true;
            }

            if (conversionHappened && deserializedObject.IsAnImplementationOf <IObjectBase>())
            {
                _eventPublisher.PublishEvent(new ObjectBaseConvertedEvent(deserializedObject.DowncastTo <IObjectBase>(), ProjectVersions.FindBy(version)));
            }
        }