public static IDataRepository Instance() { if (_instance == null) { string serverAddress = ConfigurationManager.AppSettings["ServerAddress"]; int serverPort = int.Parse(ConfigurationManager.AppSettings["ServerPort"]); var networkManager = new NetworkManager(new NetworkConfiguration(serverAddress, serverPort)); NetworkMessageHandler messageHandler = new NetworkMessageHandler(networkManager); _instance = new NetworkDataRepository(messageHandler, Application.Current.Dispatcher); } return(_instance); }
private NetworkDataRepository(NetworkMessageHandler networkMessageHandler, Dispatcher dispatcher) { _allPeople = new ObservableCollection <IPerson>(); AllPeople = new DataCollection <IPerson>(_allPeople); _allProjects = new ObservableCollection <IProject>(); AllProjects = new DataCollection <IProject>(_allProjects); _allWeeklySchedules = new ObservableCollection <IWeeklySchedule>(); AllWeeklySchedules = new DataCollection <IWeeklySchedule>(_allWeeklySchedules); _allResourceBlocks = new ObservableCollection <IResourceBlock>(); AllResourceBlocks = new DataCollection <IResourceBlock>(_allResourceBlocks); networkMessageHandler.LoadPeople(); networkMessageHandler.RegisterRepository(this); var clientNetworkMessageProcessor = new ClientNetworkMessageProcessor(dispatcher, networkMessageHandler, this); dispatcher.BeginInvoke((Action)clientNetworkMessageProcessor.ProcessMessageQueue); }