public void Apply(BaseSimulation simulation)
        {
            if (simulation == null)
            {
                throw new ArgumentNullException(nameof(simulation));
            }

            simulation.BeforeLoad += (sender, args) =>
            {
                foreach (var entity in CommonUpdates.Keys)
                {
                    var beforeLoads = CommonUpdates[entity].ParameterUpdatesBeforeLoad;

                    foreach (var entityUpdate in beforeLoads)
                    {
                        var parameter = GetEntitySimulationParameter(entityUpdate.ParameterName, entity, simulation, StringComparerProvider.Get(IsParameterNameCaseSensitive));

                        if (parameter != null)
                        {
                            Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entity);

                            var value = entityUpdate.GetValue(context);

                            if (!double.IsNaN(value))
                            {
                                parameter.Value = value;
                            }
                        }
                    }
                }

                if (SimulationSpecificUpdates.ContainsKey(simulation))
                {
                    foreach (var entityPair in SimulationSpecificUpdates[simulation])
                    {
                        var beforeLoads = entityPair.Value.ParameterUpdatesBeforeLoad;

                        foreach (var entityUpdate in beforeLoads)
                        {
                            var parameter = GetEntitySimulationParameter(entityUpdate.ParameterName, entityPair.Key, simulation, StringComparerProvider.Get(IsParameterNameCaseSensitive));

                            if (parameter != null)
                            {
                                Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entityPair.Key);

                                var value = entityUpdate.GetValue(context);
                                if (!double.IsNaN(value))
                                {
                                    parameter.Value = value;
                                }
                            }
                        }
                    }
                }
            };

            simulation.BeforeTemperature += (sender, args) =>
            {
                foreach (var entity in CommonUpdates.Keys)
                {
                    var beforeTemperature = CommonUpdates[entity].ParameterUpdatesBeforeTemperature;

                    foreach (var entityUpdate in beforeTemperature)
                    {
                        var parameter = GetEntitySimulationParameter(entityUpdate.ParameterName, entity, simulation, StringComparerProvider.Get(IsParameterNameCaseSensitive));

                        if (parameter != null)
                        {
                            Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entity);
                            var value = entityUpdate.GetValue(context);

                            if (!double.IsNaN(value))
                            {
                                parameter.Value = value;
                            }
                        }
                    }
                }

                if (SimulationSpecificUpdates.ContainsKey(simulation))
                {
                    foreach (var entityPair in SimulationSpecificUpdates[simulation])
                    {
                        var beforeTemperature = entityPair.Value.ParameterUpdatesBeforeTemperature;

                        foreach (var entityUpdate in beforeTemperature)
                        {
                            var parameter = GetEntitySimulationParameter(entityUpdate.ParameterName, entityPair.Key, simulation, StringComparerProvider.Get(IsParameterNameCaseSensitive));

                            if (parameter != null)
                            {
                                Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entityPair.Key);

                                var value = entityUpdate.GetValue(context);
                                if (!double.IsNaN(value))
                                {
                                    parameter.Value = value;
                                }
                            }
                        }
                    }
                }
            };
        }
        public void Apply(Simulation simulation)
        {
            if (simulation == null)
            {
                throw new ArgumentNullException(nameof(simulation));
            }

            if (simulation is BiasingSimulation biasingSimulation)
            {
                biasingSimulation.BeforeLoad += (sender, args) =>
                {
                    foreach (var entity in CommonUpdates.Keys)
                    {
                        var beforeLoads = CommonUpdates[entity].ParameterUpdatesBeforeLoad;

                        foreach (var entityUpdate in beforeLoads)
                        {
                            Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entity);

                            var value = entityUpdate.GetValue(context);
                            if (!double.IsNaN(value))
                            {
                                entity.CreateParameterSetter <double>(entityUpdate.ParameterName)?.Invoke(value);
                            }
                        }
                    }

                    if (SimulationSpecificUpdates.ContainsKey(simulation))
                    {
                        foreach (var entityPair in SimulationSpecificUpdates[simulation])
                        {
                            var beforeLoads = entityPair.Value.ParameterUpdatesBeforeLoad;

                            foreach (var entityUpdate in beforeLoads)
                            {
                                Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entityPair.Key);

                                var value = entityUpdate.GetValue(context);
                                if (!double.IsNaN(value))
                                {
                                    entityPair.Key.CreateParameterSetter <double>(entityUpdate.ParameterName)?.Invoke(value);
                                }
                            }
                        }
                    }
                };

                biasingSimulation.BeforeTemperature += (sender, args) =>
                {
                    foreach (var entity in CommonUpdates.Keys)
                    {
                        var beforeTemperature = CommonUpdates[entity].ParameterUpdatesBeforeTemperature;

                        foreach (var entityUpdate in beforeTemperature)
                        {
                            Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entity);

                            var value = entityUpdate.GetValue(context);
                            if (!double.IsNaN(value))
                            {
                                entity.CreateParameterSetter <double>(entityUpdate.ParameterName)?.Invoke(value);
                            }
                        }
                    }

                    if (SimulationSpecificUpdates.ContainsKey(simulation))
                    {
                        foreach (var entityPair in SimulationSpecificUpdates[simulation])
                        {
                            var beforeTemperature = entityPair.Value.ParameterUpdatesBeforeTemperature;

                            foreach (var entityUpdate in beforeTemperature)
                            {
                                Common.Evaluation.EvaluationContext context = GetEntityContext(simulation, entityPair.Key);

                                var value = entityUpdate.GetValue(context);
                                if (!double.IsNaN(value))
                                {
                                    entityPair.Key.CreateParameterSetter <double>(entityUpdate.ParameterName)?.Invoke(value);
                                }
                            }
                        }
                    }
                };
            }
        }