Exemple #1
0
        public void should_extract_handler_tokens()
        {
            EventBusIdentifier actual = EventBusRouter.ExtractIdentifier(MockHelper.GetRouterRequestContext("/mediator","string","test"));
            EventBusIdentifier expected = new EventBusIdentifier("test","string");

            Assert.That(actual,Is.EqualTo(expected));
        }
Exemple #2
0
 public static IHttpHandler ExtractHandler(EventBusIdentifier id)
 {
     if (id == null)
     {
         return new EventBusErrorHandler("bus identifier is null");
     }
     if (!EventBusManager.Current.HasBus(id))
     {
         return new EventBusErrorHandler(string.Format("Bus id [{0}] was not registred",id.Key));
     }
     Type specialType = EventBusManager.Current.GetTypeForKey(id);
     if(specialType == null)
     {
         return new EventBusErrorHandler(string.Format("the Type for the bus id [{0}] was not found",id.Key));
     }
     Type eventBusHandlerGeneric = typeof (EventBusHandler<>);
     Type[] typeArgs = { specialType };
     var eventBusHandler = eventBusHandlerGeneric.MakeGenericType(typeArgs);
     IHttpHandler result = (IHttpHandler)Activator.CreateInstance(eventBusHandler);
     return result;
 }