/// <summary>
 /// Toes the subscriptor key.
 /// </summary>
 /// <param name="subscriptionType">Type of the subscription.</param>
 /// <returns></returns>
 public static SubscriptionKey ToSubscriptorKey(this SubscriptionType subscriptionType)
 {
     var subscriptionKey = new SubscriptionKey
     {
         Key = subscriptionType.Key,
         ParentKeys = subscriptionType.ParentKeys.Select(pK => ToSubscriptorKey(pK)).ToList()
     };
     return subscriptionKey;
 }
 public void SetUp()
 {
     _identification = new Identification { Id = "Test", Type = "Test_Type" };
     _senderMessageFake = new Mock<IOutputGateway<byte[]>>();
     _senderIMessage = new Mock<IOutputGateway<byte[]>>();
     _senderIMessageFake = new Mock<IOutputGateway<byte[]>>();
     _subscriptionKey = SubscriptionKeyMessageFactory.CreateFromType(typeof(MessageFake)).ToSubscriptorKey();
     _key = string.Format("{0},{1}", typeof(MessageFake).FullName, typeof(MessageFake).Assembly.GetName().Name);
 }
        /// <summary>
        /// Toes the subscriptor key.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <returns></returns>
        public static SubscriptionKey ToSubscriptorKey(this SubscriptionKeyMessage subscription)
        {
            var subscriptionKey = new SubscriptionKey
            {
                Key        = subscription.Key,
                ParentKeys = subscription.ParentKeys.Select(pK => ToSubscriptorKey(pK)).ToList()
            };

            return(subscriptionKey);
        }
Example #4
0
        /// <summary>
        ///     Unsubscribes the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="service"></param>
        /// <param name="sender">The sender.</param>
        public void Unsubscribe(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender)
        {
            bool lockTaken = false;
            _lockSubcriptorsList.Enter(ref lockTaken);
            if (lockTaken)
            {
                try
                {
                    if (_subcriptorsList.ContainsKey(service))
                    {
                        _subcriptorsList.Remove(service);
                    }
                }
                catch (Exception exception)
                {
                    LoggerManager.Instance.Error(string.Format("Error al aƱadir suscriptor {0}", service.Id), exception);
                }
                finally
                {
                    LoggerManager.Instance.Info(string.Format("Se libera el lock {0}", service.Id));
                    _lockSubcriptorsList.Exit();
                }
            }

            _gatewaysRepository.RemoveSender(type, service, sender);
        }
 /// <summary>
 /// Determines whether [is assignable key] [the specified key1].
 /// </summary>
 /// <param name="key1">The key1.</param>
 /// <param name="key">The key.</param>
 /// <returns>
 ///     <c>true</c> if [is assignable key] [the specified key1]; otherwise, <c>false</c>.
 /// </returns>
 public static bool IsAssignableKey(this SubscriptionKey key1, string key)
 {
     return(key1.Key == key || (key1.ParentKeys != null && key1.ParentKeys.Any(subscriptionKey => subscriptionKey != null && subscriptionKey.IsAssignableKey(key))));
 }
Example #6
0
        public void SetUp()
        {
            _subscriptorsRepository = new Mock<ISubscriptorsRepository>(MockBehavior.Strict);
            _subscriptorPersister = new Mock<ISubscriptorsPersister>(MockBehavior.Strict);
            _controller = new Mock<IRouterController>(MockBehavior.Strict);
            _processor = new Mock<IProcessorFake>(MockBehavior.Strict);
            _outputControlGateway = new Mock<IOutputGateway<IControlMessage>>(MockBehavior.Strict);
            _outputGateway = new Mock<IOutputGateway<byte[]>>(MockBehavior.Strict);

            _controller.SetupGet(c => c.Processor).Returns(_processor.Object);
            _identification = new Identification { Id = "Test", Type = "Test_Type" };
            _subscriptionKey = new SubscriptionKey
                {
                    Key = string.Format("{0},{1}", typeof(string).FullName, typeof(string).Assembly.GetName().Name)
                };

            _subscriptor = new Subscriptor()
                               {
                                   Service = new Identification { Id = "Service", Type = "Service" },
                                   ServiceInputControlGateway = _outputControlGateway.Object,
                                   ServiceInputGateway = _outputGateway.Object,
                                   SubcriptionTypes = new List<SubscriptionKey> { _subscriptionKey }
                               };

            _subscriptorsRepository.Setup(r => r.Dispose());
        }
Example #7
0
 /// <summary>
 ///     Unsubscribes the specified message type.
 /// </summary>
 /// <param name="messageType">Type of the message.</param>
 /// <param name="service"></param>
 /// <param name="outputGateway">The message sender.</param>
 public void Unsubscribe(SubscriptionKey messageType, Identification service,
                         IOutputGateway<byte[]> outputGateway)
 {
     _routerOutputHelper.Unsubscribe(messageType, service, outputGateway);
 }
 /// <summary>
 ///     Removes the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public override void RemoveSender(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender)
 {
     HierarchicalKeyEngine.Remove(type, service, sender);
 }
 /// <summary>
 ///     Adds the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public override void AddSender(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender)
 {
     LoggerManager.Instance.Debug(string.Format("Add Sender: {0}", type.Key));
     HierarchicalKeyEngine.Add(type, service, sender);
 }
Example #10
0
 /// <summary>
 /// Removes the sender.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="service"></param>
 /// <param name="sender">The sender.</param>
 public abstract void RemoveSender(SubscriptionKey type, Identification service, IOutputGateway<byte[]> sender);
Example #11
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 protected bool Equals(SubscriptionKey other)
 {
     return(string.Equals(Key, other.Key));
 }
Example #12
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns></returns>
 protected bool Equals(SubscriptionKey other)
 {
     return string.Equals(Key, other.Key);
 }