Ejemplo n.º 1
0
        /// <summary>
        /// Subscribes the given subscriber to notifications of the
        /// given type of message using the supplied callback.
        /// </summary>
        /// <typeparam name="T">The type of message the subecriber is interested in.</typeparam>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="invocationModel">The invocation model.</param>
        /// <param name="callbackFilter">The filter invoked to determine if the callback shopuld be invoked.</param>
        /// <param name="callback">The callback.</param>
        public void Subscribe <T>(object subscriber, InvocationModel invocationModel, Func <object, T, bool> callbackFilter, Action <object, T> callback)
        {
            Ensure.That(subscriber).Named(() => subscriber).IsNotNull();
            Ensure.That(callback).Named(() => callback).IsNotNull();
            Ensure.That(callbackFilter).Named(() => callbackFilter).IsNotNull();

            var subscription = new PocoSubscription <T>(subscriber, callback, callbackFilter, invocationModel, this.dispatcher);

            this.SubscribeCore(typeof(T), subscription);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Subscribes the given subscriber to notifications of the
        /// given type of message using the supplied callback only.
        /// </summary>
        /// <param name="subscriber">The subscriber.</param>
        /// <param name="messageType">Type of the message.</param>
        /// <param name="invocationModel">The invocation model.</param>
        /// <param name="callbackFilter">The filter invoked to determine if the callback shopuld be invoked.</param>
        /// <param name="callback">The callback.</param>
        public void Subscribe(object subscriber, Type messageType, InvocationModel invocationModel, Func <object, object, bool> callbackFilter, Action <object, object> callback)
        {
            Ensure.That(subscriber).Named(() => subscriber).IsNotNull();
            Ensure.That(messageType).Named(() => messageType).IsNotNull();
            Ensure.That(callbackFilter).Named(() => callbackFilter).IsNotNull();
            Ensure.That(callback).Named(() => callback).IsNotNull();

            var subscription = new PocoSubscription(subscriber, callback, callbackFilter, invocationModel, this.dispatcher);

            this.SubscribeCore(messageType, subscription);
        }