예제 #1
0
        public SignalBus(
            [Inject(Source = InjectSources.Local)]
            List <SignalDeclaration> signalDeclarations,
            [Inject(Source = InjectSources.Parent, Optional = true)]
            SignalBus parentBus,
            [InjectOptional]
            ZenjectSettings zenjectSettings,
            SignalSubscription.Pool subscriptionPool,
            SignalDeclaration.Factory signalDeclarationFactory,
            DiContainer container)
        {
            _subscriptionPool         = subscriptionPool;
            zenjectSettings           = zenjectSettings ?? ZenjectSettings.Default;
            _settings                 = zenjectSettings.Signals ?? ZenjectSettings.SignalSettings.Default;
            _signalDeclarationFactory = signalDeclarationFactory;
            _container                = container;

            signalDeclarations.ForEach(x =>
            {
                if (!_localDeclarationMap.ContainsKey(x.BindingId))
                {
                    _localDeclarationMap.Add(x.BindingId, x);
                }
                else
                {
                    _localDeclarationMap[x.BindingId].Subscriptions.AllocFreeAddRange(x.Subscriptions);
                }
            });
            _parentBus = parentBus;
        }
        public SignalBus(
            [Inject(Source = InjectSources.Local)] List <SignalDeclaration> signalDeclarations,
            [Inject(Source = InjectSources.Parent, Optional = true)]
            SignalBus parentBus,
            [InjectOptional] ZenjectSettings zenjectSettings,
            SignalSubscription.Pool subscriptionPool,
            SignalDeclaration.Factory signalDeclarationFactory,
            DiContainer container)
        {
            _subscriptionPool         = subscriptionPool;
            zenjectSettings           = zenjectSettings ?? ZenjectSettings.Default;
            _settings                 = zenjectSettings.Signals ?? ZenjectSettings.SignalSettings.Default;
            _signalDeclarationFactory = signalDeclarationFactory;
            _container                = container;

            _localDeclarationMap = signalDeclarations.ToDictionary(x => x.BindingId, x => x);
            _parentBus           = parentBus;
        }