SetValue() public method

public SetValue ( string key, string value ) : void
key string
value string
return void
Example #1
0
        private void _parseElement(JsonObject json, Section section, JsonValue data)
        {
            string type = "Unknown";

            try {
                type = json["type"];
                if (type == "HiddenElement")
                {
                    var name = json.asString("id");
                    _controller.SetValue(name, data == null? json.asString("value") : data.CleanString());
                }
                else
                {
                    string id         = (json.ContainsKey("id") ? json["id"] : null);
                    var    newElement = ElementParsers.Parsers[type](json, _controller, data);
                    if (newElement != null)
                    {
                        if (!string.IsNullOrEmpty(id))
                        {
                            newElement.ID = new NSString(id);
                        }

                        section.Add(newElement);
                    }
                }
            } catch (Exception e) {
                Console.WriteLine("Problem parsing element. Element was skipped. Type: " + type + " = " + e.ToString());
            }
        }
		public override void Execute (FormDialogViewController controller, Element element, Action completed)
		{
			controller.SetValue("temperature", "");
			controller.SetValue("humidity", "");
			controller.SetValue("windspeed", "");
			
			var request = new NSMutableUrlRequest(new NSUrl("http://ws.geonames.org/weatherIcaoJSON?ICAO=KORD"), NSUrlRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData, 10);
			
			new UrlConnection("weather", request, (result)=>{
				var json = JsonObject.Parse(result);
				var weather = json["weatherObservation"];
				
				controller.SetValue("temperature", weather["temperature"].CleanString()+ " celsius");
				controller.SetValue("humidity", weather["humidity"].CleanString() + "%");
				controller.SetValue("windspeed", weather["windSpeed"].CleanString()+" km/h");
				
				controller.Reload();
				completed();
				
			}, (error)=>{
				controller.NetworkFailed(error);
				completed();
			});
		}