/// <inheritdoc/>
 public void Add(IBehaviorContainer behaviors)
 {
     behaviors.ThrowIfNull(nameof(behaviors));
     _lock.EnterUpgradeableReadLock();
     try
     {
         if (_dictionary.ContainsKey(behaviors.Name))
         {
             throw new ArgumentException(Properties.Resources.Behaviors_BehaviorsAlreadyExist.FormatString(behaviors.Name));
         }
         _lock.EnterWriteLock();
         try
         {
             _dictionary.Add(behaviors.Name, behaviors);
             _values.Add(behaviors);
         }
         finally
         {
             _lock.ExitWriteLock();
         }
     }
     finally
     {
         _lock.ExitUpgradeableReadLock();
     }
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BehaviorContainerBuilder{TContext}"/> class.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="simulation">The simulation.</param>
 /// <param name="context">The context.</param>
 public BehaviorContainerBuilder(IBehaviorContainer container, ISimulation simulation, TContext context)
 {
     _container  = container.ThrowIfNull(nameof(container));
     _simulation = simulation.ThrowIfNull(nameof(simulation));
     _context    = context;
 }