From 5cdf8903d408d0545614c4a1399cae14f7439ac2 Mon Sep 17 00:00:00 2001 From: PsychoMark Date: Tue, 12 Jul 2016 16:57:24 +0200 Subject: [PATCH] Revert "Changed Model namespace to Connection, moved bits out to Infrastructure" This reverts commit ccfde19d2d0b53901bb3caf161e907b782e1671c. --- App.xaml.cs | 7 +-- Connection/MockConnection.cs | 50 ------------------- Connection/MockConnectionFactory.cs | 17 ------- Connection/MockConnectionInfoBuilder.cs | 10 ---- Infrastructure/ListBoxAutoScroll.cs | 2 +- {Connection => Model}/ConnectionInfo.cs | 2 +- {Connection => Model}/IConnection.cs | 2 +- {Connection => Model}/IConnectionFactory.cs | 2 +- .../IConnectionInfoBuilder.cs | 2 +- .../MessageBodyRenderer.cs | 2 +- {Connection => Model}/MessageInfo.cs | 2 +- .../RabbitMQClientConnection.cs | 2 +- .../RabbitMQClientConnectionFactory.cs | 2 +- {Connection => Model}/RabbitMQProperties.cs | 2 +- {Infrastructure => Model}/UserSettings.cs | 2 +- PettingZoo.csproj | 23 ++++----- View/ConnectionWindow.xaml.cs | 3 +- ViewModel/ConnectionViewModel.cs | 2 +- ViewModel/MainViewModel.cs | 8 +-- 19 files changed, 28 insertions(+), 114 deletions(-) delete mode 100644 Connection/MockConnection.cs delete mode 100644 Connection/MockConnectionFactory.cs delete mode 100644 Connection/MockConnectionInfoBuilder.cs rename {Connection => Model}/ConnectionInfo.cs (91%) rename {Connection => Model}/IConnection.cs (96%) rename {Connection => Model}/IConnectionFactory.cs (78%) rename {Connection => Model}/IConnectionInfoBuilder.cs (72%) rename {Infrastructure => Model}/MessageBodyRenderer.cs (96%) rename {Connection => Model}/MessageInfo.cs (95%) rename {Connection => Model}/RabbitMQClientConnection.cs (99%) rename {Connection => Model}/RabbitMQClientConnectionFactory.cs (87%) rename {Connection => Model}/RabbitMQProperties.cs (95%) rename {Infrastructure => Model}/UserSettings.cs (97%) diff --git a/App.xaml.cs b/App.xaml.cs index fad383f..4089151 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -5,8 +5,7 @@ using System.Reflection; using System.Windows; using System.Windows.Markup; using Newtonsoft.Json; -using PettingZoo.Connection; -using PettingZoo.Infrastructure; +using PettingZoo.Model; using PettingZoo.View; using PettingZoo.ViewModel; using SimpleInjector; @@ -35,10 +34,6 @@ namespace PettingZoo container.Register(); container.Register(); - //container.Register(() => new MockConnectionFactory(10)); - //container.Register(); - - container.Register(); container.Register(); diff --git a/Connection/MockConnection.cs b/Connection/MockConnection.cs deleted file mode 100644 index 605cdd7..0000000 --- a/Connection/MockConnection.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; - -namespace PettingZoo.Connection -{ - public class MockConnection : IConnection - { - private Timer messageTimer; - private bool connected; - - public MockConnection(int interval) - { - messageTimer = new Timer(state => - { - if (!connected) - { - StatusChanged(this, new StatusChangedEventArgs(ConnectionStatus.Connected, "Mock")); - connected = true; - } - - MessageReceived(this, new MessageReceivedEventArgs(new MessageInfo - { - Exchange = "mock", - RoutingKey = "mock.mock", - Timestamp = DateTime.Now, - Body = Encoding.UTF8.GetBytes("Mock!"), - Properties = new Dictionary - { - { "mock", "mock" } - }})); - }, null, interval, interval); - } - - - public void Dispose() - { - if (messageTimer != null) - { - messageTimer.Dispose(); - messageTimer = null; - } - } - - - public event EventHandler StatusChanged; - public event EventHandler MessageReceived; - } -} diff --git a/Connection/MockConnectionFactory.cs b/Connection/MockConnectionFactory.cs deleted file mode 100644 index 8e91d1f..0000000 --- a/Connection/MockConnectionFactory.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace PettingZoo.Connection -{ - public class MockConnectionFactory : IConnectionFactory - { - private readonly int interval; - - public MockConnectionFactory(int interval) - { - this.interval = interval; - } - - public IConnection CreateConnection(ConnectionInfo connectionInfo) - { - return new MockConnection(interval); - } - } -} diff --git a/Connection/MockConnectionInfoBuilder.cs b/Connection/MockConnectionInfoBuilder.cs deleted file mode 100644 index 0c526e5..0000000 --- a/Connection/MockConnectionInfoBuilder.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace PettingZoo.Connection -{ - public class MockConnectionInfoBuilder : IConnectionInfoBuilder - { - public ConnectionInfo Build() - { - return new ConnectionInfo(); - } - } -} diff --git a/Infrastructure/ListBoxAutoScroll.cs b/Infrastructure/ListBoxAutoScroll.cs index 25d3e00..4d2415c 100644 --- a/Infrastructure/ListBoxAutoScroll.cs +++ b/Infrastructure/ListBoxAutoScroll.cs @@ -109,7 +109,7 @@ namespace PettingZoo.Infrastructure return; } - if (Math.Abs(scrollViewer.VerticalOffset - scrollViewer.ScrollableHeight) <= 1) + if (Math.Abs(scrollViewer.VerticalOffset - scrollViewer.ScrollableHeight) < 1) target.ScrollIntoView(e.NewItems[e.NewItems.Count - 1]); } diff --git a/Connection/ConnectionInfo.cs b/Model/ConnectionInfo.cs similarity index 91% rename from Connection/ConnectionInfo.cs rename to Model/ConnectionInfo.cs index ba4abd2..8ba3ba4 100644 --- a/Connection/ConnectionInfo.cs +++ b/Model/ConnectionInfo.cs @@ -1,4 +1,4 @@ -namespace PettingZoo.Connection +namespace PettingZoo.Model { public class ConnectionInfo { diff --git a/Connection/IConnection.cs b/Model/IConnection.cs similarity index 96% rename from Connection/IConnection.cs rename to Model/IConnection.cs index deabd60..394a721 100644 --- a/Connection/IConnection.cs +++ b/Model/IConnection.cs @@ -1,6 +1,6 @@ using System; -namespace PettingZoo.Connection +namespace PettingZoo.Model { public enum ConnectionStatus { diff --git a/Connection/IConnectionFactory.cs b/Model/IConnectionFactory.cs similarity index 78% rename from Connection/IConnectionFactory.cs rename to Model/IConnectionFactory.cs index adf0655..e1b6bd5 100644 --- a/Connection/IConnectionFactory.cs +++ b/Model/IConnectionFactory.cs @@ -1,4 +1,4 @@ -namespace PettingZoo.Connection +namespace PettingZoo.Model { public interface IConnectionFactory { diff --git a/Connection/IConnectionInfoBuilder.cs b/Model/IConnectionInfoBuilder.cs similarity index 72% rename from Connection/IConnectionInfoBuilder.cs rename to Model/IConnectionInfoBuilder.cs index 3c4e13e..bdd683c 100644 --- a/Connection/IConnectionInfoBuilder.cs +++ b/Model/IConnectionInfoBuilder.cs @@ -1,4 +1,4 @@ -namespace PettingZoo.Connection +namespace PettingZoo.Model { public interface IConnectionInfoBuilder { diff --git a/Infrastructure/MessageBodyRenderer.cs b/Model/MessageBodyRenderer.cs similarity index 96% rename from Infrastructure/MessageBodyRenderer.cs rename to Model/MessageBodyRenderer.cs index 5030eb2..1ba2e62 100644 --- a/Infrastructure/MessageBodyRenderer.cs +++ b/Model/MessageBodyRenderer.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Text; using Newtonsoft.Json; -namespace PettingZoo.Infrastructure +namespace PettingZoo.Model { public class MessageBodyRenderer { diff --git a/Connection/MessageInfo.cs b/Model/MessageInfo.cs similarity index 95% rename from Connection/MessageInfo.cs rename to Model/MessageInfo.cs index 35de946..7a29779 100644 --- a/Connection/MessageInfo.cs +++ b/Model/MessageInfo.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace PettingZoo.Connection +namespace PettingZoo.Model { public class MessageInfo { diff --git a/Connection/RabbitMQClientConnection.cs b/Model/RabbitMQClientConnection.cs similarity index 99% rename from Connection/RabbitMQClientConnection.cs rename to Model/RabbitMQClientConnection.cs index 85678f7..0cd573d 100644 --- a/Connection/RabbitMQClientConnection.cs +++ b/Model/RabbitMQClientConnection.cs @@ -8,7 +8,7 @@ using PettingZoo.Properties; using RabbitMQ.Client; using RabbitMQ.Client.Events; -namespace PettingZoo.Connection +namespace PettingZoo.Model { public class RabbitMQClientConnection : IConnection { diff --git a/Connection/RabbitMQClientConnectionFactory.cs b/Model/RabbitMQClientConnectionFactory.cs similarity index 87% rename from Connection/RabbitMQClientConnectionFactory.cs rename to Model/RabbitMQClientConnectionFactory.cs index 77cbc78..d61aa3e 100644 --- a/Connection/RabbitMQClientConnectionFactory.cs +++ b/Model/RabbitMQClientConnectionFactory.cs @@ -1,4 +1,4 @@ -namespace PettingZoo.Connection +namespace PettingZoo.Model { public class RabbitMQClientConnectionFactory : IConnectionFactory { diff --git a/Connection/RabbitMQProperties.cs b/Model/RabbitMQProperties.cs similarity index 95% rename from Connection/RabbitMQProperties.cs rename to Model/RabbitMQProperties.cs index 8d72610..a8378b5 100644 --- a/Connection/RabbitMQProperties.cs +++ b/Model/RabbitMQProperties.cs @@ -1,4 +1,4 @@ -namespace PettingZoo.Connection +namespace PettingZoo.Model { static class RabbitMQProperties { diff --git a/Infrastructure/UserSettings.cs b/Model/UserSettings.cs similarity index 97% rename from Infrastructure/UserSettings.cs rename to Model/UserSettings.cs index cd2e5eb..cefe00b 100644 --- a/Infrastructure/UserSettings.cs +++ b/Model/UserSettings.cs @@ -1,4 +1,4 @@ -namespace PettingZoo.Infrastructure +namespace PettingZoo.Model { public interface IUserSettingsSerializer { diff --git a/PettingZoo.csproj b/PettingZoo.csproj index f0ac76d..6b2b336 100644 --- a/PettingZoo.csproj +++ b/PettingZoo.csproj @@ -113,24 +113,21 @@ App.xaml Code - - - - - - - - - - - - - + + + + + + + + + + diff --git a/View/ConnectionWindow.xaml.cs b/View/ConnectionWindow.xaml.cs index 0b91428..d0e94a0 100644 --- a/View/ConnectionWindow.xaml.cs +++ b/View/ConnectionWindow.xaml.cs @@ -1,8 +1,7 @@ using System.Windows; using System.Windows.Input; using AutoMapper; -using PettingZoo.Connection; -using PettingZoo.Infrastructure; +using PettingZoo.Model; using PettingZoo.ViewModel; namespace PettingZoo.View diff --git a/ViewModel/ConnectionViewModel.cs b/ViewModel/ConnectionViewModel.cs index e4da5cb..367eb50 100644 --- a/ViewModel/ConnectionViewModel.cs +++ b/ViewModel/ConnectionViewModel.cs @@ -1,8 +1,8 @@ using System; using System.Windows.Input; using AutoMapper; -using PettingZoo.Connection; using PettingZoo.Infrastructure; +using PettingZoo.Model; namespace PettingZoo.ViewModel { diff --git a/ViewModel/MainViewModel.cs b/ViewModel/MainViewModel.cs index 6fe8ef1..e392b36 100644 --- a/ViewModel/MainViewModel.cs +++ b/ViewModel/MainViewModel.cs @@ -4,8 +4,8 @@ using System.Collections.ObjectModel; using System.Threading; using System.Threading.Tasks; using System.Windows.Input; -using PettingZoo.Connection; using PettingZoo.Infrastructure; +using PettingZoo.Model; using PettingZoo.Properties; namespace PettingZoo.ViewModel @@ -188,13 +188,13 @@ namespace PettingZoo.ViewModel if (args != null) switch (args.Status) { - case Connection.ConnectionStatus.Connecting: + case Model.ConnectionStatus.Connecting: return String.Format(Resources.StatusConnecting, args.Context); - case Connection.ConnectionStatus.Connected: + case Model.ConnectionStatus.Connected: return String.Format(Resources.StatusConnected, args.Context); - case Connection.ConnectionStatus.Error: + case Model.ConnectionStatus.Error: return String.Format(Resources.StatusError, args.Context); }