public ServiceBusRuntime(IServiceLocator serviceLocator)
        {
            try
            {
                serviceLocator = Microsoft.Practices.ServiceLocation.ServiceLocator.Current;
            }
            catch (NullReferenceException) // 1.0 throws null ref exception if no provider delegate is set.
            {
            }

            if (serviceLocator == null)
            {
                serviceLocator = SimpleServiceLocator.With(new Delivery.DirectDeliveryCore()); // default to simple service locator with direct message delivery
            }

            _serviceLocator = serviceLocator;

            attachServices();

            _subscriptionEndpoint = new SubscriptionEndpoint(Guid.Empty, "Subscription endpoint", null, null, (Type)null, new SubscriptionDispatcher(() => this.ListSubscriptions(true)), new PredicateMessageFilter(pr => false), true, null);
            _correlatorEndpoint   = new SubscriptionEndpoint(Guid.NewGuid(), "Correlator", null, null, (Type)null, new ActionDispatcher((se, md) =>
            {
                _correlator.Reply((string)md.Context[MessageDelivery.CorrelationId], md);
            }), new PredicateMessageFilter(pr => pr.Context.ContainsKey(MessageDelivery.CorrelationId)), true, null);

            Subscribe(_subscriptionEndpoint);
            Subscribe(_correlatorEndpoint);
        }
        public static SimpleServiceLocator With(params object[] services)
        {
            SimpleServiceLocator loc = new SimpleServiceLocator();

            foreach (object o in services)
            {
                loc.RegisterService(o);
            }
            return(loc);
        }
 public ServiceBusRuntime(params RuntimeService[] runtimeServices) : this(SimpleServiceLocator.With(runtimeServices))
 {
 }