public EntryViewModel() { //this.server = (CMAuthServer)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("D27678AB-DDCC-4470-A637-2DE030023E0E"))); //string test = string.Concat(Directory.GetCurrentDirectory(), "\\data\\"); //this.server.StartServer(test); Guid deviceId = Settings.Default.DeviceId; if (deviceId == Guid.Empty) { Settings @default = Settings.Default; Guid guid = Guid.NewGuid(); deviceId = guid; @default.DeviceId = guid; Settings.Default.Save(); } this.transportFactory = new TransportFactory(); this.devicePairing = new DevicePairing(deviceId, this.transportFactory, new SpcApiWrapper()); }
static async void loadController() { Guid deviceId = Settings.Default.DeviceId; if (deviceId == Guid.Empty) { Console.WriteLine("No saved device ID found"); Settings @default = Settings.Default; Guid guid = Guid.NewGuid(); deviceId = guid; @default.DeviceId = guid; Settings.Default.Save(); } else { //Console.WriteLine("Previously saved device ID found"); } transportFactory = new TransportFactory(); devicePairing = new DevicePairing(deviceId, transportFactory, new SpcApiWrapper()); IPlayerNotificationProvider playerNotificationProvider = new PlayerNotificationProvider(); IDeviceListener uPnPDeviceListener = new UPnPDeviceListener(new NetworkInfoProvider(), transportFactory); IDeviceDiscovery uPnPDeviceDiscovery = new UPnPDeviceDiscovery(transportFactory, uPnPDeviceListener); IDeviceDiscovery tvDiscovery = new TvDiscovery(uPnPDeviceDiscovery, new TcpWebTransport(TimeSpan.FromSeconds(5))); deviceController = new DeviceController(tvDiscovery, devicePairing, playerNotificationProvider, new DeviceSettingProvider()); //Console.WriteLine("Device discovery starting"); deviceController.StartDiscovery(); bool previousDeviceAsync = await deviceController.ConnectToPreviousDeviceAsync(); if (!previousDeviceAsync) { Console.WriteLine("No previously paired TV found."); loadDevice(deviceController); checkNetwork(deviceController); } else { Console.WriteLine("Previously paired TV found."); verifyNetwork(); } }