示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        SignalDeclaration GetDeclaration(BindingId signalId)
        {
            SignalDeclaration handler;

            if (_localDeclarationMap.TryGetValue(signalId, out handler))
            {
                return(handler);
            }

            if (_parentBus != null)
            {
                return(_parentBus.GetDeclaration(signalId));
            }

            return(null);
        }
示例#4
0
        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;
 }
示例#6
0
 void SubscribeInternal(BindingId signalId, object token, Action <object> callback)
 {
     SubscribeInternal(
         new SignalSubscriptionId(signalId, token), callback);
 }
示例#7
0
 void UnsubscribeInternal(BindingId signalId, object token, bool throwIfMissing)
 {
     UnsubscribeInternal(
         new SignalSubscriptionId(signalId, token), throwIfMissing);
 }
示例#8
0
        public bool IsSignalDeclared(Type signalType, object identifier)
        {
            var signalId = new BindingId(signalType, identifier);

            return(GetDeclaration(signalId) != null);
        }
示例#9
0
 public InjectContext()
 {
     _bindingId = new BindingId();
     Reset();
 }
示例#10
0
 void SetDefaults()
 {
     _callback    = null;
     _declaration = null;
     _signalId    = new BindingId();
 }