/// <summary> /// Binds the behavior to the simulation. /// </summary> /// <param name="behavior">The behavior that needs to be bound to the simulation.</param> /// <param name="simulation">The simulation to be bound to.</param> protected virtual void BindBehavior(IBehavior behavior, Simulation simulation) { simulation.ThrowIfNull(nameof(simulation)); // Build the setup behavior var context = new BindingContext(); // Add existing entity behaviors that have already been created context.Add("entity", simulation.EntityBehaviors[Name]); context.Add("entity", simulation.EntityParameters[Name]); // Finally bind the behavior to the simulation behavior.Bind(simulation, context); }
/// <summary> /// Bind a behavior to a simulation. /// </summary> /// <param name="behavior">The behavior.</param> /// <param name="simulation">The simulation.</param> protected override void BindBehavior(IBehavior behavior, Simulation simulation) { var context = BuildBindingContext(simulation); // Apply entity context context.Add("entity", simulation.EntityBehaviors[Name]); context.Add("entity", simulation.EntityParameters[Name]); // Apply model context if (!string.IsNullOrEmpty(Model)) { context.Add("model", simulation.EntityBehaviors[Model]); context.Add("model", simulation.EntityParameters[Model]); } // Apply connection context context.Connect(ApplyConnections(simulation.Variables)); behavior.Bind(simulation, context); }