public static void Refresh() { if (PublicApiGateway == null) { throw new InvalidOperationException("Labyrinth has not been created yet"); } ActiveDeviceId = null; var deviceGroups = PublicApiGateway.GetDeviceGroups(); var devices = PublicApiGateway.GetDevices(); _installedApplications.Clear(); foreach (Device device in devices) { var installedApps = PublicApiGateway.GetInstalledApplications(device.DeviceId); _installedApplications.Add(device.DeviceId, installedApps); } _devices = devices.ToDictionary(d => d.DeviceId, d => d); TotalGroups = deviceGroups.Length; TotalDevices = devices.Length; _labyrinthMatrix = MapGenerator.GenerateMap(deviceGroups, devices); }
public void GoToMaze() { var instanceUrlText = GameObject.Find("InstanceUrlText").GetComponent <Text>(); var credentialsTextBox = GameObject.Find("CredentialsText").GetComponent <Text>(); IPublicApiGateway publicApiGateway; if (instanceUrlText.text.Equals("mock", StringComparison.OrdinalIgnoreCase)) { publicApiGateway = new PublicApiGatewayMock(); } else { string[] credentialTokens = credentialsTextBox.text.Split(new[] { ":" }, StringSplitOptions.None); if (credentialTokens.Length != 4) { ShowMessage("Credentials must be in the format userName:password:clientId:clientSecret"); return; } string userName = credentialTokens[0]; string password = credentialTokens[1]; string clientId = credentialTokens[2]; string clientSecret = credentialTokens[3]; publicApiGateway = new PublicApiGateway(instanceUrlText.text, clientId, clientSecret, userName, password); try { ShowMessage("Please wait..."); Game.GenerateLabyrinth(publicApiGateway); } catch (Exception ex) { ShowMessage("Failed to retrieve data from MobiControl public API. Make sure that the values you entered are correct. Details :" + ex.Message); return; } } Application.LoadLevel("labyrinth"); }