private void WireUpListeners() { var listeners = Assimilate.GetAllInstancesOf <IEventListener>(); listeners.ForEach(listener => { if (listener.ListenSubTypesOfEvent) { var includedTargeTypes = Reflector.GetSubTypes(listener.EventType); includedTargeTypes.ForEach(eventType => AddListener(listener, eventType)); } else { AddListener(listener, listener.EventType); } }); }
public void WireupDispatchers() { if (Dispatchers.Count == 0) { var dispatchers = Assimilate.GetAllInstancesOf <IDispatchMessage>(); dispatchers .ForEach(x => x.Handles.ForEach(y => Dispatchers.AddOrUpdate(y, x, (t, m) => x))); } // prevent duplicate instantiations var agency = Assimilate.GetInstanceOf <IAgency>(); agency.RegisterActorOf("", this); // prime director //Fibers.Send("", new Envelope<PrimeDirector>(new PrimeDirector()) { CorrelationId = "" }); Loop.Enqueue(() => SendToHandler("", new Envelope <PrimeDirector>(new PrimeDirector()) { CorrelationId = "" })); Signal.Wait(100); }
/// <summary> /// Gets all instances of IRule types from the IoC container and builds /// up a list of the target types (the "T" in IRule<T>) and loads them /// in the Rules dictionary with rules assigned to that type (as well as assigning /// those rules to sub-types). /// </summary> private void ScanAndLoadRules() { Rules.Clear(); var rules = Assimilate.GetAllInstancesOf <IRule>().Distinct().ToList(); rules.ForEach(rule => { var ruleTargetType = FindRuleTargetType(rule.GetType()); if (ruleTargetType == null) { return; } var ruleTargetChildren = Reflector.GetSubTypes(ruleTargetType).ToList(); ruleTargetChildren .ForEach(domainType => { List <IRule> ruleList = null; if (Rules.TryGetValue(domainType, out ruleList)) { if (!ruleList.Contains(rule)) { ruleList.Add(rule); } } else { ruleList = new List <IRule>() { rule }; Rules.TryAdd(domainType, ruleList); } }); }); }
protected static void WireUpCommandMock(IHttpAction commandMock) { var mock = Assimilate.GetAllInstancesOf <IHttpAction>(); Assimilate.Dependencies(x => x.For <IHttpAction>().Use(commandMock)); }