public Draft() { InitializeComponent(); model = ObjectPool.Instance.Resolve <MessageCollaborator>(); if (this.DataContext == null && model != null) { this.DataContext = model.DraftSource; } }
public MainWindowViewModel(ServerConfiguration serverConfiguration, MessageCollaborator messageCollection, ApplicationSettings applicationSettings, GeneralView generalView, CallView callView, PortView portView, SMSView smsView) { this.serverConfiguration = serverConfiguration; this.messageCollection = messageCollection; this.applicationSettings = applicationSettings; this.generalView = generalView; this.callView = callView; this.portView = portView; this.smsView = smsView; }
internal bool LoadServerConfiguration(IGatewayService service) { Server.ServerConfiguration serverConfiguration; IDataSyncronize message; IDataSyncronize contact; serverConfiguration = ObjectPool.Instance.Resolve <Server.ServerConfiguration>(); message = ObjectPool.Instance.Resolve <MessageCollaborator>(); contact = ObjectPool.Instance.Resolve <DatabaseCollectionViewSource>(); //if (serverConfiguration == null) // comment this if you want refresh connection { if (serverConfiguration == null) { serverConfiguration = new Server.ServerConfiguration(service); } if (message == null) { message = new MessageCollaborator(); } if (contact == null) { contact = new DatabaseCollectionViewSource(); } message.StartSyncronizing(); contact.StartSyncronizing(); ObjectPool.Instance.Register <SMSGatewayWpf.ViewModels.Devices.SMSView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.SMSView()); ObjectPool.Instance.Register <SMSGatewayWpf.ViewModels.Devices.CallView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.CallView()); ObjectPool.Instance.Register <SMSGatewayWpf.ViewModels.Devices.PortView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.PortView()); ObjectPool.Instance.Register <SMSGatewayWpf.ViewModels.Devices.GeneralView>().ImplementedBy(new SMSGatewayWpf.ViewModels.Devices.GeneralView()); } ObjectPool.Instance.Register <Server.ServerConfiguration>().ImplementedBy(serverConfiguration); ObjectPool.Instance.Register <MessageCollaborator>().ImplementedBy(message); ObjectPool.Instance.Register <DatabaseCollectionViewSource>().ImplementedBy(contact); OnConfigurationLoaded(); // comment due to disabled load configuration server //if (serverConfiguration.General == null) // return false; //else return(true); }
public void RouteConnection() { Task.Factory.StartNew(() => { Commands.IsBusy = true; IGatewayService service = GatewayManager.Instance.GetService(); if (service != null) { if (!service.Connection.Connected) { ApplicationSettings settings = ObjectPool.Instance.Resolve <ApplicationSettings>(); ((TcpConnection)service.Connection).IPAddress = settings.Gateway.IPAddress; ((TcpConnection)service.Connection).Port = settings.Gateway.Port; if (service.Connection.Connect()) { if (LoadServerConfiguration(service)) { Commands.ButtonContent = "Disconnect"; } } } else { if (service.Connection.Disconnect()) { /// Unregister all, excepts IDbManager, IAudioService, IDialogService, ApplicationSettings MessageCollaborator message = ObjectPool.Instance.Resolve <MessageCollaborator>(); message.StopSyncronizing(); ObjectPool.Instance.Unregister <SMSView>(); ObjectPool.Instance.Unregister <CallView>(); ObjectPool.Instance.Unregister <PortView>(); ObjectPool.Instance.Unregister <GeneralView>(); ObjectPool.Instance.Unregister <ServerConfiguration>(); ObjectPool.Instance.Unregister <MessageCollaborator>(); ObjectPool.Instance.Unregister <DatabaseCollectionViewSource>(); Commands.ButtonContent = "Connect"; } } } Commands.IsBusy = false; }); }