System.Collections.Concurrent.ConcurrentDictionary.ContainsKey(Simulation)

Here are the examples of the csharp api System.Collections.Concurrent.ConcurrentDictionary.ContainsKey(Simulation) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

19 Source : EntityUpdates.cs
with MIT License
from SpiceSharp

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

            if (simulation is BiasingSimulation biasingSimulation)
            {
                biasingSimulation.BeforeTemperature += (_, _) =>
                {
                    foreach (var enreplacedy in CommonUpdates.Keys)
                    {
                        var beforeTemperature = CommonUpdates[enreplacedy].ParameterUpdatesBeforeTemperature;

                        foreach (var enreplacedyUpdate in beforeTemperature)
                        {
                            EvaluationContext context = GetEnreplacedyContext(simulation, enreplacedy.Name);
                            if (context != null)
                            {
                                var value = enreplacedyUpdate.GetValue(context);
                                if (!double.IsNaN(value))
                                {
                                    enreplacedy.CreateParameterSetter<double>(enreplacedyUpdate.ParameterName)?.Invoke(value);
                                }
                            }
                        }
                    }
                };

                biasingSimulation.BeforeTemperature += (_, _) =>
                {
                    if (SimulationSpecificUpdates.ContainsKey(simulation))
                    {
                        foreach (var enreplacedyPair in SimulationSpecificUpdates[simulation])
                        {
                            var beforeTemperature = enreplacedyPair.Value.ParameterUpdatesBeforeTemperature;

                            foreach (var enreplacedyUpdate in beforeTemperature)
                            {
                                EvaluationContext context = GetEnreplacedyContext(simulation, enreplacedyPair.Key.Name);
                                if (context != null)
                                {
                                    var value = enreplacedyUpdate.GetValue(context);
                                    if (!double.IsNaN(value))
                                    {
                                        enreplacedyPair.Key.CreateParameterSetter<double>(enreplacedyUpdate.ParameterName)?.Invoke(value);
                                    }
                                }
                            }
                        }
                    }
                };
            }
        }

19 Source : EntityUpdates.cs
with MIT License
from SpiceSharp

public void Add(IEnreplacedy enreplacedy, string parameterName, string expression, bool beforeTemperature, Simulation simulation)
        {
            if (enreplacedy == null)
            {
                throw new ArgumentNullException(nameof(enreplacedy));
            }

            if (parameterName == null)
            {
                throw new ArgumentNullException(nameof(parameterName));
            }

            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            if (!SimulationSpecificUpdates.ContainsKey(simulation))
            {
                SimulationSpecificUpdates[simulation] = new Dictionary<IEnreplacedy, EnreplacedyUpdate>();
            }

            if (!SimulationSpecificUpdates[simulation].ContainsKey(enreplacedy))
            {
                SimulationSpecificUpdates[simulation][enreplacedy] = new EnreplacedyUpdate();
            }

            if (beforeTemperature)
            {
                SimulationSpecificUpdates[simulation][enreplacedy].ParameterUpdatesBeforeTemperature.Add(new EnreplacedyParameterExpressionValueUpdate()
                {
                    Expression = new DynamicExpression(expression),
                    ParameterName = parameterName,
                });
            }
        }

19 Source : EntityUpdates.cs
with MIT License
from SpiceSharp

public void Add(IEnreplacedy enreplacedy, string parameterName, double value, bool beforeTemperature, Simulation simulation)
        {
            if (enreplacedy == null)
            {
                throw new ArgumentNullException(nameof(enreplacedy));
            }

            if (simulation == null)
            {
                throw new ArgumentNullException(nameof(simulation));
            }

            if (parameterName == null)
            {
                throw new ArgumentNullException(nameof(parameterName));
            }

            if (!SimulationSpecificUpdates.ContainsKey(simulation))
            {
                SimulationSpecificUpdates[simulation] = new Dictionary<IEnreplacedy, EnreplacedyUpdate>();
            }

            if (!SimulationSpecificUpdates[simulation].ContainsKey(enreplacedy))
            {
                SimulationSpecificUpdates[simulation][enreplacedy] = new EnreplacedyUpdate();
            }

            if (beforeTemperature)
            {
                SimulationSpecificUpdates[simulation][enreplacedy].ParameterUpdatesBeforeTemperature.Add(new EnreplacedyParameterDoubleValueUpdate { ParameterName = parameterName, Value = value });
            }
        }

19 Source : SimulationUpdates.cs
with MIT License
from SpiceSharp

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

            // Apply common updates
            simulation.BeforeSetup += (_, _) =>
            {
                foreach (var action in CommonBeforeSetupActions)
                {
                    action.Run(simulation, Contexts);
                }

                if (SimulationBeforeSetupActions.ContainsKey(simulation))
                {
                    var actions = SimulationBeforeSetupActions[simulation];

                    foreach (var action in actions)
                    {
                        action.Run(simulation, Contexts);
                    }
                }
            };

            BiasingSimulation biasingSimulation = simulation as BiasingSimulation;
            if (biasingSimulation != null)
            {
                biasingSimulation.BeforeTemperature += (_, _) =>
                {
                    foreach (var action in CommonBeforeTemperatureActions)
                    {
                        action.Run(simulation, Contexts);
                    }

                    if (SimulationBeforeTemperatureActions.ContainsKey(simulation))
                    {
                        var actions = SimulationBeforeTemperatureActions[simulation];

                        foreach (var action in actions)
                        {
                            action.Run(simulation, Contexts);
                        }
                    }
                };
            }
        }

19 Source : SimulationUpdates.cs
with MIT License
from SpiceSharp

public void AddBeforeSetup(Simulation simulation, Action<Simulation, SimulationEvaluationContexts> action)
        {
            if (simulation == null)
            {
                throw new ArgumentNullException(nameof(simulation));
            }

            if (!SimulationBeforeSetupActions.ContainsKey(simulation))
            {
                SimulationBeforeSetupActions[simulation] = new List<SimulationUpdateAction>() { new SimulationUpdateAction(action) };
            }
            else
            {
                SimulationBeforeSetupActions[simulation].Add(new SimulationUpdateAction(action));
            }
        }

19 Source : SimulationUpdates.cs
with MIT License
from SpiceSharp

public void AddBeforeTemperature(Simulation simulation, Action<Simulation, SimulationEvaluationContexts> action)
        {
            if (simulation == null)
            {
                throw new ArgumentNullException(nameof(simulation));
            }

            if (!SimulationBeforeTemperatureActions.ContainsKey(simulation))
            {
                SimulationBeforeTemperatureActions[simulation] = new List<SimulationUpdateAction>() { new SimulationUpdateAction(action) };
            }
            else
            {
                SimulationBeforeTemperatureActions[simulation].Add(new SimulationUpdateAction(action));
            }
        }