Exemplo n.º 1
0
        public IEnumerable<Message> GetMessages(string topicName, int iteration)
        {
            IServiceBusConfig config = null;
            if (ServiceLocator.Current != null)
            {
                config = ServiceLocator.Current.GetInstance<IServiceBusConfig>();
            }

            if (config != null)
            {
                var serializer = new JsonTextSerializer();
                return from e in config.GetTopicMessages(topicName, iteration)
                       select (Message)serializer.Deserialize(new StreamReader(e.GetBody<Stream>()));
            }

            return new List<Message>();
        }
Exemplo n.º 2
0
        public static void Register(HttpConfiguration config)
        {
            var container = new UnityContainer();

            container.RegisterType<IMessageSender, TopicSender>();
            container.RegisterType<IServiceBusConfig, ServiceBusConfig>();
            var metadata = new StandardMetadataProvider();
            var serializer = new JsonTextSerializer();

            AppSettingsServiceBusConfig serviceBusConfig = new AppSettingsServiceBusConfig("", container);
            container.RegisterInstance(serviceBusConfig.Settings);

            container.RegisterInstance(new TopicRepository());
            config.DependencyResolver = new UnityDependencyResolver(container);

            Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(
                new Microsoft.Practices.ServiceLocation.ServiceLocatorProvider(() => new Microsoft.Practices.Unity.ServiceLocatorAdapter.UnityServiceLocator(container)));
        }