public void OnSpawned( Action <object> callback, SignalDeclaration declaration) { Assert.IsNull(_callback); _callback = callback; _declaration = declaration; // Cache this in case OnDeclarationDespawned is called _signalId = declaration.BindingId; declaration.Add(this); }
public SignalDeclaration( SignalDeclarationBindInfo bindInfo, [InjectOptional] UniDiSettings UniDiSettings) { UniDiSettings = UniDiSettings ?? UniDiSettings.Default; _settings = UniDiSettings.Signals ?? UniDiSettings.SignalSettings.Default; _bindingId = new BindingId(bindInfo.SignalType, bindInfo.Identifier); _missingHandlerResponses = bindInfo.MissingHandlerResponse; _isAsync = bindInfo.RunAsync; TickPriority = bindInfo.TickPriority; }
SignalDeclaration GetDeclaration(BindingId signalId) { SignalDeclaration handler; if (_localDeclarationMap.TryGetValue(signalId, out handler)) { return(handler); } if (_parentBus != null) { return(_parentBus.GetDeclaration(signalId)); } return(null); }
private void InternalFire(Type signalType, object signal, object identifier, bool requireDeclaration) { var signalId = new BindingId(signalType, identifier); // Do this before creating the signal so that it throws if the signal was not declared var declaration = GetDeclaration(signalId); if (declaration == null) { if (requireDeclaration) { throw Assert.CreateException("Fired undeclared signal '{0}'!", signalId); } } else { if (signal == null) { signal = Activator.CreateInstance(signalType); } declaration.Fire(signal); } }
public SignalSubscriptionId(BindingId signalId, object callback) { _signalId = signalId; _callback = callback; }
void SubscribeInternal(BindingId signalId, object token, Action <object> callback) { SubscribeInternal( new SignalSubscriptionId(signalId, token), callback); }
void UnsubscribeInternal(BindingId signalId, object token, bool throwIfMissing) { UnsubscribeInternal( new SignalSubscriptionId(signalId, token), throwIfMissing); }
public bool IsSignalDeclared(Type signalType, object identifier) { var signalId = new BindingId(signalType, identifier); return(GetDeclaration(signalId) != null); }
public InjectContext() { _bindingId = new BindingId(); Reset(); }
void SetDefaults() { _callback = null; _declaration = null; _signalId = new BindingId(); }