Ejemplo n.º 1
0
 public InstanceMethodSignalHandler(
     BindingId signalId, SignalManager manager, InjectContext lookupContext,
     Func <THandler, Action> methodGetter)
     : base(signalId, manager, lookupContext)
 {
     _methodGetter = methodGetter;
 }
Ejemplo n.º 2
0
        void Construct(SignalManager manager, SignalSettings settings, BindInfo bindInfo)
        {
            _manager = manager;

            SignalId = new BindingId(this.GetType(), bindInfo.Identifier);
            Settings = settings;
        }
        public void FinalizeBinding(DiContainer container)
        {
            if (BindInfo.ContractTypes.IsEmpty())
            {
                // We could assert her instead but it is nice when used with things like
                // BindInterfaces() (and there aren't any interfaces) to allow
                // interfaces to be added later
                return;
            }

            OnFinalizeBinding(container);

            if (BindInfo.NonLazy)
            {
                // Note that we can't simply use container.BindRootResolve here because
                // binding finalizers must only use RegisterProvider to allow cloning / bind
                // inheritance to work properly
                var bindingId = new BindingId(
                    typeof(object), DiContainer.DependencyRootIdentifier);

                foreach (var contractType in BindInfo.ContractTypes)
                {
                    container.RegisterProvider(
                        bindingId, null, new ResolveProvider(
                            contractType, container, BindInfo.Identifier, false,
                            // We always want to only use local here so that we can use
                            // NonLazy() inside subcontainers
                            InjectSources.Local));
                }
            }
        }
 public StaticMethodWithInstanceSignalHandler(
     BindingId signalId, SignalManager manager, InjectContext lookupContext,
     Action <THandler> method)
     : base(signalId, manager, lookupContext)
 {
     _method = method;
 }
Ejemplo n.º 5
0
        public InstanceMethodSignalHandlerBase(
            BindingId signalId, SignalManager manager,
            InjectContext lookupContext)
            : base(signalId, manager)
        {
            Assert.IsEqual(lookupContext.MemberType, typeof(THandler));

            _lookupContext = lookupContext;
        }
Ejemplo n.º 6
0
        List <ISignalHandler> GetList(BindingId signalType)
        {
            List <ISignalHandler> handlers;

            if (!_signalHandlers.TryGetValue(signalType, out handlers))
            {
                handlers = new List <ISignalHandler>();
                _signalHandlers.Add(signalType, handlers);
            }

            return(handlers);
        }
Ejemplo n.º 7
0
        // Returns true the signal was handled
        public bool Trigger(BindingId signalType, object[] args)
        {
            var handlers = GetList(signalType);

            if (handlers.Count == 0)
            {
                return(false);
            }

#if UNITY_EDITOR && ZEN_PROFILING_ENABLED
            using (ProfileBlock.Start("Signal '{0}'", signalType))
#endif
            {
                foreach (var handler in handlers)
                {
                    handler.Execute(args);
                }
            }

            return(true);
        }
 public SignalHandlerBase(
     BindingId signalId, SignalManager manager)
 {
     _manager  = manager;
     _signalId = signalId;
 }
Ejemplo n.º 9
0
 public void Unregister(BindingId signalType, ISignalHandler handler)
 {
     GetList(signalType).RemoveWithConfirm(handler);
 }
Ejemplo n.º 10
0
 public void Register(BindingId signalType, ISignalHandler handler)
 {
     GetList(signalType).Add(handler);
 }
Ejemplo n.º 11
0
 public bool IsHandlerRegistered(BindingId signalType)
 {
     return(GetList(signalType).Count > 0);
 }
Ejemplo n.º 12
0
 public int GetNumHandlers(BindingId signalType)
 {
     return(GetList(signalType).Count());
 }
Ejemplo n.º 13
0
 public StaticMethodSignalHandler(
     BindingId signalId, SignalManager manager, Action method)
     : base(signalId, manager)
 {
     _method = method;
 }