public bool RemoveReactor(ReactorBase reactor) { lock (syncRoot) { return(reactors.Remove(reactor)); } }
public void AddReactor(ReactorBase reactor) { lock (syncRoot) { reactors.Add(reactor); } }
public void Remove(ReactorBase reactor) { string referenceName = reactor.GetType().FullName + ":" + reactor.Name; if (reactors.TryRemove(referenceName, out Tuple <ReactorIsland, ReactorBase> removed)) { reactor.AttachedToRepository(null, null); removed.Item1.RemoveReactor(removed.Item2); } }
public ReactorIsland Add(ReactorBase reactor, int reactorIslandIndex = -1) { string referenceName = reactor.GetType().FullName + ":" + reactor.Name; int index = reactorIslandIndex; if (index < 0) { index = Interlocked.Increment(ref currentIsland); index = index < 0 ? -index : index; } var island = islands[index % islands.Length]; if (!reactors.TryAdd(referenceName, new Tuple <ReactorIsland, ReactorBase>(island, reactor))) { throw new ReactorException($"Failed to add reactor {referenceName}, it already exists"); } reactor.AttachedToRepository(Resolve(reactor.GetType(), reactor.Name), this); island.AddReactor(reactor); return(island); }
public static ReactorIsland AddToGlobal(ReactorBase reactor) { return(Global.Add(reactor)); }
public LocalReactorReference(string name, ReactorBase reactor) { Reference = name; this.reactor = reactor; }