Ejemplo n.º 1
0
        private void _processContentOfFile(string file, string values)
        {
            var        json      = _parse(file);
            JsonObject valueJson = null;

            if (!string.IsNullOrEmpty(values))
            {
                if (values.StartsWith(Constants.Http))
                {
                    Context = new FormBindingContext(this, json, Title);
                    Loading = true;
                    var req = CreateRequestForUrl(values);
                    new UrlConnection(Constants.UrlConnectionNameData, req, (string result) => {
                        InvokeOnMainThread(() => {
                            JsonValue resultValue = null;
                            try {
                                resultValue = JsonObject.Parse(result);
                            } catch (Exception) {
                                //Console.WriteLine("Exception while parsing result: " +e.ToString() +" Values: " + values);
                                return;
                            }

                            if (resultValue.JsonType == JsonType.Object)
                            {
                                valueJson = (JsonObject)resultValue;
                            }

                            Context = new FormBindingContext(this, json, resultValue, Title);
                            _configureDialog(json, valueJson);
                            PrepareRoot(Context.Root);
                            ReloadData();
                            Loading = false;
                        });
                    }, (error) => { NetworkFailed(error); });
                }
                else
                {
                    var datavalue = JsonObject.Parse(File.ReadAllText(NSBundle.MainBundle.PathForResource(values, "json")));
                    Context = new FormBindingContext(this, json, datavalue, Title);
                }
            }
            else
            {
                Context = new FormBindingContext(this, json, Title);
                Loading = false;
            }

            _configureDialog(json, valueJson);
            PrepareRoot(Context.Root);
            LoadView();
            ReloadData();
        }
		private void _processContentOfFile(string file, string values){
			
			var json = _parse(file);
			JsonObject valueJson = null;
			
			if (!string.IsNullOrEmpty(values)){
				
				if (values.StartsWith(Constants.Http)){
					
					Context = new FormBindingContext(this, json, Title);
					Loading = true;
					var req = CreateRequestForUrl(values);
					new UrlConnection(Constants.UrlConnectionNameData, req, (string result)=>{
						InvokeOnMainThread(()=>{
							JsonValue resultValue = null;
							try {
								resultValue = JsonObject.Parse(result);
							
							} catch (Exception){
								//Console.WriteLine("Exception while parsing result: " +e.ToString() +" Values: " + values);
								return;
								
							}
							
							if (resultValue.JsonType==JsonType.Object)
								valueJson = (JsonObject)resultValue;
						
							Context = new FormBindingContext(this, json,  resultValue, Title);
							_configureDialog(json, valueJson);
							PrepareRoot(Context.Root);
							ReloadData();
							Loading = false;
							
						});
					}, (error)=>{ NetworkFailed(error); });
					
				} else {
					var datavalue = JsonObject.Parse(File.ReadAllText(NSBundle.MainBundle.PathForResource(values, "json")));
					Context = new FormBindingContext(this, json, datavalue, Title);
				}
					
			} else {
				Context = new FormBindingContext(this, json, Title);
				Loading = false;
			}
			
			_configureDialog(json, valueJson);
			PrepareRoot(Context.Root);
			LoadView();
			ReloadData();
		}