static void Main(string[] args) { Console.WriteLine("hello client"); WeatherFactory factory = new WeatherFactory(); Location l = new Location("london", "uk"); IweatherDataService adi = factory.WeatherService(l); adi.GetWeatherData(l,"4f3cbed25685e619c16d94f45e622782"); }
public static void createLocation() { orgIdPassed = OrganizationTest.getOrgId(); LocationJSON json = new LocationJSON(orgIdPassed, "suite", "street", "suddenValley", "um", "Murica", "A2A2A2"); json.locDesc = "desc"; json.locSubType = "subtype"; json.locType = "type"; Location newLoc = new Location(TestGlobals.adminServer, json); Test mTest = new Test(newLoc); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = AuthenticateTest.getSessionToken(); AsyncContext.Run(async () => await new HTTPSCalls().runTest(mTest, HTTPOperation.POST, client)); //Assert.AreEqual("201", HTTPSCalls.result.Value); Console.WriteLine(HTTPSCalls.result.Value); TestGlobals.locIdCreated = HTTPSCalls.result.Value.Substring(9, HTTPSCalls.result.Value.Length - 10); Console.WriteLine(HTTPSCalls.result.Value.Substring(9, HTTPSCalls.result.Value.Length - 10) + " Written to testGlobals"); }
public void addLocation(Location venue) { if (venue is Park) { parks.Add((Park)venue); ((Park)venue).city = this; } else if (venue is TrainStation) { this.trainStations.Add((TrainStation)venue); ((TrainStation)venue).city = this; } else if (venue is School) { this.schools.Add((School)venue); ((School)venue).city = this; } else if (venue is Hospital) { this.hospitals.Add((Hospital)venue); ((Hospital)venue).city = this; } else { this.venues.Add(venue); } }
/* 1234567890123456789 */ public Game() { var mapRows = this.map.Replace("\r\n", "\n").Trim().Split('\n'); this.Tiles = new Matrix<Tile>(new Tile[mapRows[0].Length, mapRows.Length]); foreach (var x in this.Tiles.HorizontalRange) { foreach (var y in this.Tiles.VerticalRange) { this.Tiles[x, y] = Tile.Dot; switch (mapRows[this.Tiles.Height - y - 1][x]) { case '+': case '|': case '-': this.Tiles[x, y] = Tile.Wall; break; case 'C': this.PlayerLocation = new Location(x, y); this.Tiles[x, y] = Tile.Blank; break; case 'G': this.GhostLocations.Add(new Location(x, y)); break; case '*': this.Tiles[x, y] = Tile.BigDot; break; } } } }
bool TryMoveGhostBy(int id, int dx, int dy) { Location newLocation = new Location(this.GhostLocations[id].x + dx, this.GhostLocations[id].y + dy); if (this.Tiles.GetAt(newLocation) != Game.Tile.l) { this.GhostLocations[id] = newLocation; return true; } else return false; }
public void MoveBy(int dx, int dy) { Location newLocation = new Location(PlayerLocation.x + dx, PlayerLocation.y + dy); if (this.Tiles.GetAt(newLocation) != Game.Tile.Wall) { this.PlayerLocation = newLocation; if (this.Big > 0) this.Big--; } if (this.Tiles.GetAt(this.PlayerLocation) == Game.Tile.Dot) this.Tiles.SetAt(this.PlayerLocation, Game.Tile.Blank); if (this.Tiles.GetAt(this.PlayerLocation) == Game.Tile.BigDot) { this.Tiles.SetAt(this.PlayerLocation, Game.Tile.Blank); this.Big = 8; } CollisionCheck(); if (Won) this.OnGameOver(this, true); }
//[Test()] public static void invalidOrgID() { orgIdPassed = "invalid"; LocationJSON json = new LocationJSON (orgIdPassed, "suite", "street", "suddenValley", "um", "Murica", "A2A2A2"); json.locDesc = "desc"; json.locSubType = "subtype"; json.locType = "type"; Location newLoc = new Location (TestGlobals.adminServer, json); Test mTest = new Test (newLoc); HttpClient client = new HttpClient (); client.DefaultRequestHeaders.Authorization = AuthenticateTest.getSessionToken (); AsyncContext.Run (async () => await new HTTPSCalls().runTest (mTest, HTTPOperation.POST, client)); string statusCode = HTTPSCalls.result.Key.Property ("StatusCode").Value.ToString (); Assert.AreEqual ("400", statusCode); locStore = HTTPSCalls.result; }
static void Main(string[] args) { WeatherFactory factory = new WeatherFactory(); Location loc = new Location("london", "uk"); IweatherDataService func1 = factory.WeatherService(loc); func1.GetWeatherData(loc, Key); Console.ReadLine(); }
Data IweatherDataService.GetWeatherData(Location loc, String key) { String urlParameters; urlParameters = "?q="+ loc.city + "," + loc.country + "&APPID=" + key; HttpClient client = new HttpClient(); client.BaseAddress = new Uri(URL); // Add an Accept header for Json format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); // List data response. HttpResponseMessage response = client.GetAsync(urlParameters).Result; // Blocking call! if (response.IsSuccessStatusCode) { Console.WriteLine(response); // Parse the response body. Blocking! try { data = response.Content.ReadAsAsync<Data>().Result; Console.WriteLine("city:" + data.name + ", city ID:" + data.id); Console.WriteLine(data.ToString()); } catch (Exception e) { Console.WriteLine(e.Message); } } else { Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase); } return data; }
//use getYouTubeData method to get object that implements IyouTubeDataService interface public IweatherDataService WeatherService(Location loc) { if (loc == null) { return null; } if (string.Equals( loc.city, "london", StringComparison.OrdinalIgnoreCase)) { IweatherDataService obj = MyUploads.getInstance(); return obj; } if (!string.Equals(loc.city, "london", StringComparison.OrdinalIgnoreCase)) { throw new WeatherDataServiceException(); } return null; }