Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: WindowsFormsApplication1.ServerResponse
- // Assembly: WindowsFormsApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: A0967493-2B5E-45DB-9F7E-6A0B14E2A48A
- // Assembly location: C:\Users\yonka\Desktop\WeatherClient\WeatherClient.exe
- using System.Collections.Generic;
- namespace WindowsFormsApplication1
- {
- internal class ServerResponse
- {
- public static string TEST_RESPONSE = "200:ANSWER:date=18/07/2016&city=Beersheba&temp=29.16&text=Clear : few clouds";
- private int code;
- private float temperture;
- private string date;
- private string location;
- private string text;
- public ServerResponse(string raw_response)
- {
- this.code = int.Parse(raw_response.Substring(0, 3));
- if (this.code == 200)
- {
- string[] strArray1 = raw_response.Substring(11).Split('&');
- Dictionary<string, string> dictionary = new Dictionary<string, string>();
- foreach (string str in strArray1)
- {
- char[] chArray = new char[1]{ '=' };
- string[] strArray2 = str.Split(chArray);
- dictionary[strArray2[0]] = strArray2[1];
- }
- this.temperture = float.Parse(dictionary["temp"]);
- this.date = dictionary[nameof (date)];
- this.location = dictionary["city"];
- this.text = dictionary[nameof (text)];
- }
- else
- {
- if (this.code != 500)
- return;
- this.temperture = -1f;
- this.date = "error";
- this.location = "error";
- this.text = "error";
- }
- }
- public int getCode() => this.code;
- public float getTemperture() => this.temperture;
- public string getDate() => this.date;
- public string getLocation() => this.location;
- public string getText() => this.text;
- }
- }
Add Comment
Please, Sign In to add comment